basic linux compatibily
This commit is contained in:
parent
960c239bea
commit
7f4840a299
|
@ -54,7 +54,6 @@ SOURCES += \
|
|||
settingsdialog/editormiscwidget.cpp \
|
||||
settingsdialog/editorsnippetwidget.cpp \
|
||||
settingsdialog/editortooltipswidget.cpp \
|
||||
settingsdialog/environmentfileassociationwidget.cpp \
|
||||
settingsdialog/environmentfolderswidget.cpp \
|
||||
settingsdialog/environmentperformancewidget.cpp \
|
||||
settingsdialog/environmentshortcutwidget.cpp \
|
||||
|
@ -69,7 +68,6 @@ SOURCES += \
|
|||
settingsdialog/projectmakefilewidget.cpp \
|
||||
settingsdialog/projectoutputwidget.cpp \
|
||||
settingsdialog/projectprecompilewidget.cpp \
|
||||
settingsdialog/projectversioninfowidget.cpp \
|
||||
settingsdialog/toolsgeneralwidget.cpp \
|
||||
shortcutmanager.cpp \
|
||||
symbolusagemanager.cpp \
|
||||
|
@ -179,7 +177,6 @@ HEADERS += \
|
|||
settingsdialog/editormiscwidget.h \
|
||||
settingsdialog/editorsnippetwidget.h \
|
||||
settingsdialog/editortooltipswidget.h \
|
||||
settingsdialog/environmentfileassociationwidget.h \
|
||||
settingsdialog/environmentfolderswidget.h \
|
||||
settingsdialog/environmentperformancewidget.h \
|
||||
settingsdialog/environmentshortcutwidget.h \
|
||||
|
@ -194,7 +191,6 @@ HEADERS += \
|
|||
settingsdialog/projectmakefilewidget.h \
|
||||
settingsdialog/projectoutputwidget.h \
|
||||
settingsdialog/projectprecompilewidget.h \
|
||||
settingsdialog/projectversioninfowidget.h \
|
||||
settingsdialog/toolsgeneralwidget.h \
|
||||
shortcutmanager.h \
|
||||
symbolusagemanager.h \
|
||||
|
@ -274,7 +270,6 @@ FORMS += \
|
|||
settingsdialog/editormiscwidget.ui \
|
||||
settingsdialog/editorsnippetwidget.ui \
|
||||
settingsdialog/editortooltipswidget.ui \
|
||||
settingsdialog/environmentfileassociationwidget.ui \
|
||||
settingsdialog/environmentfolderswidget.ui \
|
||||
settingsdialog/environmentperformancewidget.ui \
|
||||
settingsdialog/environmentshortcutwidget.ui \
|
||||
|
@ -289,7 +284,6 @@ FORMS += \
|
|||
settingsdialog/projectmakefilewidget.ui \
|
||||
settingsdialog/projectoutputwidget.ui \
|
||||
settingsdialog/projectprecompilewidget.ui \
|
||||
settingsdialog/projectversioninfowidget.ui \
|
||||
settingsdialog/toolsgeneralwidget.ui \
|
||||
widgets/aboutdialog.ui \
|
||||
widgets/cpudialog.ui \
|
||||
|
@ -312,6 +306,18 @@ FORMS += \
|
|||
widgets/searchdialog.ui \
|
||||
widgets/signalmessagedialog.ui
|
||||
|
||||
win32: FORMS += \
|
||||
settingsdialog/projectversioninfowidget.ui \
|
||||
settingsdialog/environmentfileassociationwidget.ui
|
||||
|
||||
win32: HEADERS += \
|
||||
settingsdialog/projectversioninfowidget.h \
|
||||
settingsdialog/environmentfileassociationwidget.h
|
||||
|
||||
win32: SOURCES += \
|
||||
settingsdialog/environmentfileassociationwidget.cpp \
|
||||
settingsdialog/projectversioninfowidget.cpp
|
||||
|
||||
TRANSLATIONS += \
|
||||
RedPandaIDE_zh_CN.ts
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "executablerunner.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <QDebug>
|
||||
#include "compilermanager.h"
|
||||
#include "../settings.h"
|
||||
#include "../systemconsts.h"
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
ExecutableRunner::ExecutableRunner(const QString &filename, const QString &arguments, const QString &workDir
|
||||
,QObject* parent):
|
||||
|
@ -76,6 +79,12 @@ void ExecutableRunner::run()
|
|||
}
|
||||
env.insert("PATH",path);
|
||||
mProcess->setProcessEnvironment(env);
|
||||
connect(
|
||||
mProcess.get(), &QProcess::errorOccurred,
|
||||
[&errorOccurred](){
|
||||
errorOccurred= true;
|
||||
});
|
||||
#ifdef Q_OS_WIN
|
||||
mProcess->setCreateProcessArgumentsModifier([this](QProcess::CreateProcessArguments * args){
|
||||
if (mStartConsole) {
|
||||
args->flags |= CREATE_NEW_CONSOLE;
|
||||
|
@ -85,20 +94,6 @@ void ExecutableRunner::run()
|
|||
args->startupInfo -> dwFlags &= ~STARTF_USESTDHANDLES;
|
||||
}
|
||||
});
|
||||
connect(
|
||||
mProcess.get(), &QProcess::errorOccurred,
|
||||
[&errorOccurred](){
|
||||
errorOccurred= true;
|
||||
});
|
||||
// if (!redirectInput()) {
|
||||
// process.closeWriteChannel();
|
||||
// }
|
||||
mProcess->start();
|
||||
mProcess->waitForStarted(5000);
|
||||
if (mProcess->state()==QProcess::Running && redirectInput()) {
|
||||
mProcess->write(readFileToByteArray(redirectInputFilename()));
|
||||
mProcess->closeWriteChannel();
|
||||
}
|
||||
HANDLE hSharedMemory=INVALID_HANDLE_VALUE;
|
||||
int BUF_SIZE=1024;
|
||||
char* pBuf=nullptr;
|
||||
|
@ -123,55 +118,55 @@ void ExecutableRunner::run()
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// if (!redirectInput()) {
|
||||
// process.closeWriteChannel();
|
||||
// }
|
||||
mProcess->start();
|
||||
mProcess->waitForStarted(5000);
|
||||
if (mProcess->state()==QProcess::Running && redirectInput()) {
|
||||
mProcess->write(readFileToByteArray(redirectInputFilename()));
|
||||
mProcess->closeWriteChannel();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
mProcess->waitForFinished(1000);
|
||||
if (mProcess->state()!=QProcess::Running) {
|
||||
break;
|
||||
}
|
||||
if (mStop) {
|
||||
qDebug()<<"??1";
|
||||
mProcess->closeReadChannel(QProcess::StandardOutput);
|
||||
mProcess->closeReadChannel(QProcess::StandardError);
|
||||
mProcess->closeWriteChannel();
|
||||
qDebug()<<"??2";
|
||||
#ifdef Q_OS_WIN
|
||||
qDebug()<<"??3";
|
||||
mProcess->terminate();
|
||||
qDebug()<<"??4";
|
||||
if (mProcess->waitForFinished(1000)) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
process->terminate();
|
||||
if (process->waitForFinished(1000)) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
for (int i=0;i<10;i++) {
|
||||
qDebug()<<"??5";
|
||||
mProcess->kill();
|
||||
qDebug()<<"??6";
|
||||
if (mProcess->waitForFinished(500)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
if (mStartConsole && !mPausing && pBuf) {
|
||||
if (strncmp(pBuf,"FINISHED",sizeof("FINISHED"))==0) {
|
||||
setPausing(true);
|
||||
emit pausingForFinish();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (errorOccurred)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (pBuf)
|
||||
UnmapViewOfFile(pBuf);
|
||||
if (hSharedMemory!=INVALID_HANDLE_VALUE)
|
||||
CloseHandle(hSharedMemory);
|
||||
#endif
|
||||
if (errorOccurred) {
|
||||
//qDebug()<<"process error:"<<process.error();
|
||||
switch (mProcess->error()) {
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
#include "platform.h"
|
||||
#include "parser/parserutils.h"
|
||||
#include "editorlist.h"
|
||||
#ifdef Q_WIN_OS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WIN_OS
|
||||
class WindowLogoutEventFilter : public QAbstractNativeEventFilter {
|
||||
|
||||
// QAbstractNativeEventFilter interface
|
||||
|
@ -46,6 +49,7 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/
|
|||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString getSettingFilename(const QString& filepath = QString()) {
|
||||
QString filename;
|
||||
|
@ -154,8 +158,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
mainWindow.show();
|
||||
#ifdef Q_WIN_OS
|
||||
WindowLogoutEventFilter filter;
|
||||
app.installNativeEventFilter(&filter);
|
||||
#endif
|
||||
int retCode = app.exec();
|
||||
QString configDir = pSettings->dirs().config();
|
||||
// save settings
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <windows.h>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "editorlist.h"
|
||||
|
@ -52,6 +51,11 @@
|
|||
|
||||
#include <widgets/searchdialog.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
|
||||
for (int i=0;i<tabWidget->count();i++) {
|
||||
if (w==tabWidget->widget(i))
|
||||
|
@ -867,6 +871,11 @@ QPlainTextEdit *MainWindow::txtLocals()
|
|||
return ui->txtLocals;
|
||||
}
|
||||
|
||||
QMenuBar *MainWindow::menuBar() const
|
||||
{
|
||||
return ui->menubar;
|
||||
}
|
||||
|
||||
void MainWindow::updateStatusbarForLineCol()
|
||||
{
|
||||
Editor* e = mEditorList->getEditor();
|
||||
|
@ -2684,10 +2693,12 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand)
|
|||
QProcess process;
|
||||
process.setWorkingDirectory(folder);
|
||||
process.setProgram(shellCommand);
|
||||
#ifdef Q_OS_WIN
|
||||
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){
|
||||
args->flags |= CREATE_NEW_CONSOLE;
|
||||
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES; //
|
||||
});
|
||||
#endif
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
QStringList pathAdded;
|
||||
|
@ -5456,12 +5467,6 @@ void MainWindow::applyCurrentProblemCaseChanges()
|
|||
}
|
||||
}
|
||||
|
||||
Ui::MainWindow *MainWindow::mainWidget() const
|
||||
{
|
||||
return ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_btnReplace_clicked()
|
||||
{
|
||||
//select all items by default
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
QPlainTextEdit* txtLocals();
|
||||
|
||||
Ui::MainWindow* mainWidget() const;
|
||||
QMenuBar* menuBar() const;
|
||||
|
||||
CPUDialog *cpuDialog() const;
|
||||
|
||||
|
|
|
@ -4,20 +4,25 @@
|
|||
#include <QMap>
|
||||
#include <QSet>
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
CharsetInfoManager* pCharsetInfoManager;
|
||||
|
||||
QByteArray CharsetInfoManager::getDefaultSystemEncoding()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
DWORD acp = GetACP();
|
||||
PCharsetInfo info = findCharsetByCodepage(acp);
|
||||
if (info) {
|
||||
return info->name;
|
||||
}
|
||||
return "unknown";
|
||||
#else
|
||||
return QByteArray(nl_langinfo(CODESET));
|
||||
#endif
|
||||
}
|
||||
|
||||
PCharsetInfo CharsetInfoManager::findCharsetByCodepage(int codepage)
|
||||
|
|
|
@ -2036,8 +2036,8 @@ bool ProjectModel::canDropMimeData(const QMimeData * data, Qt::DropAction action
|
|||
QByteArray encoded = data->data(format);
|
||||
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
||||
while (!stream.atEnd()) {
|
||||
int r, c;
|
||||
intptr_t v;
|
||||
qint32 r, c;
|
||||
quintptr v;
|
||||
stream >> r >> c >> v;
|
||||
FolderNode* droppedPointer= (FolderNode*)(v);
|
||||
PFolderNode droppedNode = mProject->pointerToNode(droppedPointer);
|
||||
|
@ -2076,8 +2076,8 @@ bool ProjectModel::dropMimeData(const QMimeData *data, Qt::DropAction action, in
|
|||
QVector<int> rows,cols;
|
||||
QVector<intptr_t> pointers;
|
||||
while (!stream.atEnd()) {
|
||||
int r, c;
|
||||
intptr_t v;
|
||||
qint32 r, c;
|
||||
quintptr v;
|
||||
stream >> r >> c >> v;
|
||||
rows.append(r);
|
||||
cols.append(c);
|
||||
|
@ -2124,7 +2124,7 @@ QMimeData *ProjectModel::mimeData(const QModelIndexList &indexes) const
|
|||
QModelIndexList::ConstIterator it = indexes.begin();
|
||||
QList<QUrl> urls;
|
||||
for (; it != indexes.end(); ++it) {
|
||||
stream << (*it).row() << (*it).column() << (intptr_t)((*it).internalPointer());
|
||||
stream << (qint32)((*it).row()) << (qint32)((*it).column()) << (quintptr)((*it).internalPointer());
|
||||
FolderNode* p = static_cast<FolderNode*>((*it).internalPointer());
|
||||
if (p && p->unitIndex>=0) {
|
||||
urls.append(QUrl::fromLocalFile(mProject->units()[p->unitIndex]->fileName()));
|
||||
|
|
|
@ -45,7 +45,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
mFontDummy = QFont("Consolas",12);
|
||||
#elif Q_OS_LINUX
|
||||
#elif defined(Q_OS_LINUX)
|
||||
mFontDummy = QFont("terminal",14);
|
||||
#else
|
||||
#error "Not supported!"
|
||||
|
|
|
@ -2469,7 +2469,7 @@ void Settings::CompilerSets::saveSets()
|
|||
}
|
||||
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
|
||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_COUNT,mList.size());
|
||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_COUNT,(int)mList.size());
|
||||
mSettings->mSettings.endGroup();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,5 +69,4 @@ protected:
|
|||
void doLoad() override;
|
||||
void doSave() override;
|
||||
};
|
||||
|
||||
#endif // ENVIRONMENTFILEASSOCIATIONWIDGET_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "environmentshortcutwidget.h"
|
||||
#include "ui_environmentshortcutwidget.h"
|
||||
#include "../mainwindow.h"
|
||||
#include "../ui_mainwindow.h"
|
||||
#include <QMenuBar>
|
||||
|
||||
EnvironmentShortcutWidget::EnvironmentShortcutWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
|
@ -42,7 +42,7 @@ void EnvironmentShortcutModel::reload()
|
|||
beginResetModel();
|
||||
mShortcuts.clear();
|
||||
QList<QAction*> actions = pMainWindow->findChildren<QAction*>(QString(),Qt::FindDirectChildrenOnly);
|
||||
QList<QMenu*> menus = pMainWindow->mainWidget()->menubar->findChildren<QMenu*>();
|
||||
QList<QMenu*> menus = pMainWindow->menuBar()->findChildren<QMenu*>();
|
||||
foreach( const QMenu* menu, menus) {
|
||||
if (menu->title().isEmpty())
|
||||
continue;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "editormiscwidget.h"
|
||||
#include "environmentappearencewidget.h"
|
||||
#include "environmentshortcutwidget.h"
|
||||
#include "environmentfileassociationwidget.h"
|
||||
#include "environmentfolderswidget.h"
|
||||
#include "environmentperformancewidget.h"
|
||||
#include "executorgeneralwidget.h"
|
||||
|
@ -31,9 +30,12 @@
|
|||
#include "projectprecompilewidget.h"
|
||||
#include "projectoutputwidget.h"
|
||||
#include "projectmakefilewidget.h"
|
||||
#include "projectversioninfowidget.h"
|
||||
#include "projectdllhostwidget.h"
|
||||
#include "toolsgeneralwidget.h"
|
||||
#ifdef Q_OS_WIN
|
||||
#include "environmentfileassociationwidget.h"
|
||||
#include "projectversioninfowidget.h"
|
||||
#endif
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QModelIndex>
|
||||
|
@ -113,9 +115,11 @@ PSettingsDialog SettingsDialog::optionDialog()
|
|||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
widget = new EnvironmentFileAssociationWidget(tr("File Association"),tr("Environment"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
#endif
|
||||
|
||||
widget = new EnvironmentShortcutWidget(tr("Shortcuts"),tr("Environment"));
|
||||
widget->init();
|
||||
|
@ -254,9 +258,11 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
|
|||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
widget = new ProjectVersionInfoWidget(tr("Version info"),tr("Project"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
#endif
|
||||
|
||||
dialog->selectFirstWidget();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define GDB_PROGRAM "gdb"
|
||||
#define GDB32_PROGRAM "gdb32"
|
||||
#define MAKE_PROGRAM "make"
|
||||
#define WINDRES_PROGRAM ""
|
||||
#define GPROF_PROGRAM "gprof"
|
||||
#define CLEAN_PROGRAM "rm -rf"
|
||||
#define CPP_PROGRAM "cpp"
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
#include <QTextCodec>
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <QStyleFactory>
|
||||
#include <QDateTime>
|
||||
#include <QColor>
|
||||
|
@ -95,6 +97,7 @@ static bool gIsGreenEdition = true;
|
|||
static bool gIsGreenEditionInited = false;
|
||||
bool isGreenEdition()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if (!gIsGreenEditionInited) {
|
||||
QString keyString = QString("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RedPanda-C++");
|
||||
QString value;
|
||||
|
@ -114,6 +117,9 @@ bool isGreenEdition()
|
|||
gIsGreenEditionInited = true;
|
||||
}
|
||||
return gIsGreenEdition;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments,
|
||||
|
@ -280,6 +286,7 @@ void splitStringArguments(const QString &arguments, QStringList &argumentList)
|
|||
|
||||
bool programHasConsole(const QString &filename)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
bool result = false;
|
||||
HANDLE handle = CreateFile(filename.toStdWString().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
|
@ -299,6 +306,9 @@ bool programHasConsole(const QString &filename)
|
|||
}
|
||||
CloseHandle(handle);
|
||||
return result;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList textToLines(const QString &text)
|
||||
|
@ -890,6 +900,8 @@ bool haveGoodContrast(const QColor& c1, const QColor &c2) {
|
|||
return std::abs(lightness1 - lightness2)>=120;
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QString& value) {
|
||||
DWORD dataSize;
|
||||
LONG result;
|
||||
|
@ -914,6 +926,7 @@ bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QSt
|
|||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<QByteArray> splitByteArrayToLines(const QByteArray &content)
|
||||
{
|
||||
|
|
|
@ -199,7 +199,10 @@ QString fromByteArray(const QByteArray& s);
|
|||
|
||||
int getNewFileNumber();
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool readRegistry(HKEY key,const QByteArray& subKey, const QByteArray& name, QString& value);
|
||||
#endif
|
||||
|
||||
class CppParser;
|
||||
void resetCppParser(std::shared_ptr<CppParser> parser);
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
<customwidget>
|
||||
<class>SynEdit</class>
|
||||
<extends>QFrame</extends>
|
||||
<header location="global">qsynedit/Synedit.h</header>
|
||||
<header location="global">qsynedit/SynEdit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
|
Loading…
Reference in New Issue