├── .gitignore ├── LICENSE ├── Lemon_zh_CN.ts ├── README.md ├── add.png ├── addcompilerwizard.cpp ├── addcompilerwizard.h ├── addtaskdialog.cpp ├── addtaskdialog.h ├── addtestcaseswizard.cpp ├── addtestcaseswizard.h ├── advancedcompilersettingsdialog.cpp ├── advancedcompilersettingsdialog.h ├── assignmentthread.cpp ├── assignmentthread.h ├── clean ├── compiler.cpp ├── compiler.h ├── compilersettings.cpp ├── compilersettings.h ├── contest.cpp ├── contest.h ├── contestant.cpp ├── contestant.h ├── core.pro ├── cross.png ├── crossplatformhelper.h ├── detaildialog.cpp ├── detaildialog.h ├── downarrow.png ├── editvariabledialog.cpp ├── editvariabledialog.h ├── environmentvariablesdialog.cpp ├── environmentvariablesdialog.h ├── exportutil.cpp ├── exportutil.h ├── filelineedit.cpp ├── filelineedit.h ├── forms_unix ├── addcompilerwizard.ui ├── addtaskdialog.ui ├── addtestcaseswizard.ui ├── advancedcompilersettingsdialog.ui ├── compilersettings.ui ├── detaildialog.ui ├── editvariabledialog.ui ├── environmentvariablesdialog.ui ├── generalsettings.ui ├── judgingdialog.ui ├── lemon.ui ├── newcontestdialog.ui ├── newcontestwidget.ui ├── opencontestdialog.ui ├── opencontestwidget.ui ├── optionsdialog.ui ├── taskeditwidget.ui ├── testcaseeditwidget.ui └── welcomedialog.ui ├── forms_win32 ├── addcompilerwizard.ui ├── addtaskdialog.ui ├── addtestcaseswizard.ui ├── advancedcompilersettingsdialog.ui ├── compilersettings.ui ├── detaildialog.ui ├── editvariabledialog.ui ├── environmentvariablesdialog.ui ├── generalsettings.ui ├── judgingdialog.ui ├── lemon.ui ├── newcontestdialog.ui ├── newcontestwidget.ui ├── opencontestdialog.ui ├── opencontestwidget.ui ├── optionsdialog.ui ├── taskeditwidget.ui ├── testcaseeditwidget.ui └── welcomedialog.ui ├── generalsettings.cpp ├── generalsettings.h ├── globaltype.h ├── icon.icns ├── icon.ico ├── icon.png ├── judge ├── judge.pro └── realjudge.c ├── judgingdialog.cpp ├── judgingdialog.h ├── judgingthread.cpp ├── judgingthread.h ├── lemon.cpp ├── lemon.h ├── lemon.pro ├── lemon.rc ├── main.cpp ├── make ├── newcontestdialog.cpp ├── newcontestdialog.h ├── newcontestwidget.cpp ├── newcontestwidget.h ├── opencontestdialog.cpp ├── opencontestdialog.h ├── opencontestwidget.cpp ├── opencontestwidget.h ├── optionsdialog.cpp ├── optionsdialog.h ├── qt_zh_CN.qm ├── qtlockedfile ├── qtlockedfile.cpp ├── qtlockedfile.h ├── qtlockedfile_unix.cpp └── qtlockedfile_win.cpp ├── qtsingleapplication ├── qtlocalpeer.cpp ├── qtlocalpeer.h ├── qtsingleapplication.cpp ├── qtsingleapplication.h ├── qtsinglecoreapplication.cpp └── qtsinglecoreapplication.h ├── resource.qrc ├── resultviewer.cpp ├── resultviewer.h ├── rod.png ├── selftestutil.cpp ├── selftestutil.h ├── settings.cpp ├── settings.h ├── summarytree.cpp ├── summarytree.h ├── task.cpp ├── task.h ├── taskeditwidget.cpp ├── taskeditwidget.h ├── testcase.cpp ├── testcase.h ├── testcaseeditwidget.cpp ├── testcaseeditwidget.h ├── uparrow.png ├── watcher ├── watcher_unix.c └── watcher_unix.pro ├── welcomedialog.cpp └── welcomedialog.h /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | moc_*.h 24 | qrc_*.cpp 25 | ui_*.h 26 | Makefile* 27 | *build-* 28 | 29 | # QtCreator 30 | 31 | *.autosave 32 | 33 | # QtCtreator Qml 34 | *.qmlproject.user 35 | *.qmlproject.user.* 36 | 37 | # QtCtreator CMake 38 | CMakeLists.txt.user* 39 | 40 | #Lemon 41 | Lemon_zh_CN.qm 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lemon 2 | 为 OI 赛制设计的简易评测环境。 3 | 4 | 本评测环境没有沙盒,请不要用于评测不可信的代码。 5 | 6 | 原版作者为 [@zhipeng-jia](https://github.com/zhipeng-jia),此版本为修改版本。 7 | 8 | 目前该版本已支持 Windows 和 Linux 平台,由于我没有 Mac 所以没法测试 MacOS平台,如果发现 MacOS 下有 bug 请在 issue 区提出。 9 | 10 | ## 该版本特性 11 | 12 | * 支持选手目录下建立子文件夹。 13 | * 修改了最大内存限制和最大时间限制。 14 | * Linux 和 Win 平台自动开无限栈(Linux 平台需要系统支持)。 15 | 16 | ## Flags: 17 | 18 | * 从 syzoj 的 data.yml 中导入数据。 19 | * 有好的建议欢迎在 issue 区中提出。 20 | 21 | ## 安装 22 | 23 | 直接下载 release 中的预编译包(目前已有 Windows 和 Linux 平台的预编译包),或按照下面的方式编译。 24 | 25 | ## 编译 26 | 首先安装 Qt5 SDK。 27 | 28 | 然后依次执行以下命令: 29 | 30 | ```shell 31 | git clone https://github.com/WAAutoMaton/Lemon 32 | cd Lemon 33 | qmake lemon.pro 34 | make 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/add.png -------------------------------------------------------------------------------- /addcompilerwizard.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDCOMPILERWIZARD_H 2 | #define ADDCOMPILERWIZARD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class AddCompilerWizard; 12 | } 13 | 14 | class Compiler; 15 | 16 | class AddCompilerWizard : public QWizard 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit AddCompilerWizard(QWidget *parent = 0); 22 | ~AddCompilerWizard(); 23 | void accept(); 24 | const QList& getCompilerList() const; 25 | 26 | private: 27 | Ui::AddCompilerWizard *ui; 28 | QList compilerList; 29 | int nextId() const; 30 | bool validateCurrentPage(); 31 | 32 | private slots: 33 | void compilerTypeChanged(); 34 | void selectCompilerLocation(); 35 | void selectInterpreterLocation(); 36 | void selectGccPath(); 37 | void selectGppPath(); 38 | void selectFpcPath(); 39 | void selectFbcPath(); 40 | void selectJavacPath(); 41 | void selectJavaPath(); 42 | void selectPythonPath(); 43 | }; 44 | 45 | #endif // ADDCOMPILERWIZARD_H 46 | -------------------------------------------------------------------------------- /addtaskdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "addtaskdialog.h" 20 | #include "ui_addtaskdialog.h" 21 | #include "settings.h" 22 | 23 | AddTaskDialog::AddTaskDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::AddTaskDialog) 26 | { 27 | ui->setupUi(this); 28 | 29 | ui->fullScore->setValidator(new QIntValidator(1, Settings::upperBoundForFullScore() * 100, this)); 30 | ui->timeLimit->setValidator(new QIntValidator(1, Settings::upperBoundForTimeLimit(), this)); 31 | ui->memoryLimit->setValidator(new QIntValidator(1, Settings::upperBoundForMemoryLimit(), this)); 32 | 33 | connect(ui->taskBox, SIGNAL(currentIndexChanged(int)), 34 | this, SLOT(taskBoxIndexChanged())); 35 | connect(ui->fullScore, SIGNAL(textChanged(QString)), 36 | this, SLOT(fullScoreChanged())); 37 | connect(ui->timeLimit, SIGNAL(textChanged(QString)), 38 | this, SLOT(timeLimitChanged())); 39 | connect(ui->memoryLimit, SIGNAL(textChanged(QString)), 40 | this, SLOT(memoryLimitChanged())); 41 | } 42 | 43 | AddTaskDialog::~AddTaskDialog() 44 | { 45 | delete ui; 46 | } 47 | 48 | void AddTaskDialog::addTask(const QString &title, int _fullScore, int _timeLimit, int _memoryLimit) 49 | { 50 | fullScore.append(_fullScore); 51 | timeLimit.append(_timeLimit); 52 | memoryLimit.append(_memoryLimit); 53 | ui->taskBox->addItem(title); 54 | ui->taskBox->setCurrentIndex(0); 55 | } 56 | 57 | int AddTaskDialog::getFullScore(int index) const 58 | { 59 | if (0 <= index && index < fullScore.size()) { 60 | return fullScore[index]; 61 | } else { 62 | return 0; 63 | } 64 | } 65 | 66 | int AddTaskDialog::getTimeLimit(int index) const 67 | { 68 | if (0 <= index && index < timeLimit.size()) { 69 | return timeLimit[index]; 70 | } else { 71 | return 0; 72 | } 73 | } 74 | 75 | int AddTaskDialog::getMemoryLimit(int index) const 76 | { 77 | if (0 <= index && index < memoryLimit.size()) { 78 | return memoryLimit[index]; 79 | } else { 80 | return 0; 81 | } 82 | } 83 | 84 | void AddTaskDialog::taskBoxIndexChanged() 85 | { 86 | int index = ui->taskBox->currentIndex(); 87 | ui->fullScore->setText(QString("%1").arg(fullScore[index])); 88 | ui->timeLimit->setText(QString("%1").arg(timeLimit[index])); 89 | ui->memoryLimit->setText(QString("%1").arg(memoryLimit[index])); 90 | } 91 | 92 | void AddTaskDialog::fullScoreChanged() 93 | { 94 | int index = ui->taskBox->currentIndex(); 95 | fullScore[index] = ui->fullScore->text().toInt(); 96 | } 97 | 98 | void AddTaskDialog::timeLimitChanged() 99 | { 100 | int index = ui->taskBox->currentIndex(); 101 | timeLimit[index] = ui->timeLimit->text().toInt(); 102 | } 103 | 104 | void AddTaskDialog::memoryLimitChanged() 105 | { 106 | int index = ui->taskBox->currentIndex(); 107 | memoryLimit[index] = ui->memoryLimit->text().toInt(); 108 | } 109 | -------------------------------------------------------------------------------- /addtaskdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ADDTASKDIALOG_H 20 | #define ADDTASKDIALOG_H 21 | 22 | #include 23 | 24 | namespace Ui { 25 | class AddTaskDialog; 26 | } 27 | 28 | class AddTaskDialog : public QDialog 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit AddTaskDialog(QWidget *parent = 0); 34 | ~AddTaskDialog(); 35 | void addTask(const QString&, int, int, int); 36 | int getFullScore(int) const; 37 | int getTimeLimit(int) const; 38 | int getMemoryLimit(int) const; 39 | 40 | private: 41 | Ui::AddTaskDialog *ui; 42 | QList fullScore; 43 | QList timeLimit; 44 | QList memoryLimit; 45 | 46 | private slots: 47 | void taskBoxIndexChanged(); 48 | void fullScoreChanged(); 49 | void timeLimitChanged(); 50 | void memoryLimitChanged(); 51 | }; 52 | 53 | #endif // ADDTASKDIALOG_H 54 | -------------------------------------------------------------------------------- /addtestcaseswizard.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef ADDTESTCASESWIZARD_H 21 | #define ADDTESTCASESWIZARD_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ui { 29 | class AddTestCasesWizard; 30 | } 31 | 32 | class Settings; 33 | 34 | class AddTestCasesWizard : public QWizard 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit AddTestCasesWizard(QWidget *parent = 0); 40 | ~AddTestCasesWizard(); 41 | void setSettings(Settings*, bool); 42 | int getFullScore() const; 43 | int getTimeLimit() const; 44 | int getMemoryLimit() const; 45 | const QList& getMatchedInputFiles() const; 46 | const QList& getMatchedOutputFiles() const; 47 | 48 | private: 49 | Ui::AddTestCasesWizard *ui; 50 | Settings *settings; 51 | int fullScore; 52 | int timeLimit; 53 | int memoryLimit; 54 | QString inputFilesPattern; 55 | QString outputFilesPattern; 56 | QList matchedInputFiles; 57 | QList matchedOutputFiles; 58 | void refreshButtonState(); 59 | void getFiles(const QString&, const QString&, QStringList&); 60 | QString getFullRegExp(const QString&); 61 | QStringList getMatchedPart(const QString&, const QString&); 62 | void searchMatchedFiles(); 63 | bool validateCurrentPage(); 64 | static bool compareFileName(const QString&, const QString&); 65 | 66 | private slots: 67 | void fullScoreChanged(const QString&); 68 | void timeLimitChanged(const QString&); 69 | void memoryLimitChanged(const QString&); 70 | void inputFilesPatternChanged(const QString&); 71 | void outputFilesPatternChanged(const QString&); 72 | void addArgument(); 73 | void deleteArgument(); 74 | }; 75 | 76 | #endif // ADDTESTCASESWIZARD_H 77 | -------------------------------------------------------------------------------- /advancedcompilersettingsdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef ADVANCEDCOMPILERSETTINGSDIALOG_H 21 | #define ADVANCEDCOMPILERSETTINGSDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class Compiler; 30 | 31 | namespace Ui { 32 | class AdvancedCompilerSettingsDialog; 33 | } 34 | 35 | class AdvancedCompilerSettingsDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit AdvancedCompilerSettingsDialog(QWidget *parent = 0); 41 | ~AdvancedCompilerSettingsDialog(); 42 | void resetEditCompiler(Compiler*); 43 | Compiler* getEditCompiler() const; 44 | 45 | private: 46 | Ui::AdvancedCompilerSettingsDialog *ui; 47 | Compiler *editCompiler; 48 | int configCount; 49 | 50 | private slots: 51 | void okayButtonClicked(); 52 | void compilerTypeChanged(); 53 | void compilerLocationChanged(); 54 | void interpreterLocationChanged(); 55 | void selectCompilerLocation(); 56 | void selectInterpreterLocation(); 57 | void bytecodeExtensionsChanged(); 58 | void timeLimitRatioChanged(); 59 | void memoryLimitRatioChanged(); 60 | void disableMemoryLimitCheckChanged(); 61 | void configurationIndexChanged(); 62 | void configurationTextChanged(); 63 | void deleteConfiguration(); 64 | void compilerArgumentsChanged(); 65 | void interpreterArgumentsChanged(); 66 | void environmentVariablesButtonClicked(); 67 | }; 68 | 69 | #endif // ADVANCEDCOMPILERSETTINGSDIALOG_H 70 | -------------------------------------------------------------------------------- /assignmentthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ASSIGNMENTTHREAD_H 20 | #define ASSIGNMENTTHREAD_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Settings; 27 | class Task; 28 | class JudgingThread; 29 | 30 | class AssignmentThread : public QThread 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit AssignmentThread(QObject *parent = 0); 35 | void setCheckRejudgeMode(bool); 36 | void setNeedRejudge(const QList< QPair >&); 37 | void setSettings(Settings*); 38 | void setTask(Task*); 39 | void setContestantName(const QString&); 40 | CompileState getCompileState() const; 41 | const QString& getCompileMessage() const; 42 | const QString& getSourceFile() const; 43 | const QList< QList >& getScore() const; 44 | const QList< QList >& getTimeUsed() const; 45 | const QList< QList >& getMemoryUsed() const; 46 | const QList< QList >& getResult() const; 47 | const QList& getMessage() const; 48 | const QList& getInputFiles() const; 49 | const QList< QPair >& getNeedRejudge() const; 50 | void run(); 51 | 52 | private: 53 | bool checkRejudgeMode; 54 | bool interpreterFlag; 55 | Settings *settings; 56 | Task* task; 57 | QString contestantName; 58 | CompileState compileState; 59 | QString compileMessage; 60 | QString sourceFile; 61 | QString executableFile; 62 | QString arguments; 63 | QString diffPath; 64 | double timeLimitRatio; 65 | double memoryLimitRatio; 66 | bool disableMemoryLimitCheck; 67 | QProcessEnvironment environment; 68 | QList< QList > timeUsed; 69 | QList< QList > memoryUsed; 70 | QList< QList > score; 71 | QList< QList > result; 72 | QList message; 73 | QList inputFiles; 74 | QList< QPair > needRejudge; 75 | int curTestCaseIndex; 76 | int curSingleCaseIndex; 77 | int countFinished; 78 | int totalSingleCase; 79 | QMap< JudgingThread*, QPair > running; 80 | bool stopJudging; 81 | bool traditionalTaskPrepare(); 82 | void assign(); 83 | 84 | private slots: 85 | void threadFinished(); 86 | 87 | public slots: 88 | void stopJudgingSlot(); 89 | 90 | signals: 91 | void singleCaseFinished(int, int, int, int); 92 | void compileError(int, int); 93 | void stopJudgingSignal(); 94 | }; 95 | 96 | #endif // ASSIGNMENTTHREAD_H 97 | -------------------------------------------------------------------------------- /clean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Project Lemon - A tiny judging environment for OI contest 4 | # Copyright (C) 2016 Menci 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | make clean 21 | rm -rf *.o moc_* ui_* *.lib *.Lib Makefile* watcher_unix 22 | -------------------------------------------------------------------------------- /compiler.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "compiler.h" 20 | 21 | Compiler::Compiler(QObject *parent) : 22 | QObject(parent) 23 | { 24 | compilerType = Typical; 25 | timeLimitRatio = 1; 26 | memoryLimitRatio = 1; 27 | disableMemoryLimitCheck = false; 28 | } 29 | 30 | Compiler::CompilerType Compiler::getCompilerType() const 31 | { 32 | return compilerType; 33 | } 34 | 35 | const QString& Compiler::getCompilerName() const 36 | { 37 | return compilerName; 38 | } 39 | 40 | const QStringList& Compiler::getSourceExtensions() const 41 | { 42 | return sourceExtensions; 43 | } 44 | 45 | const QString& Compiler::getCompilerLocation() const 46 | { 47 | return compilerLocation; 48 | } 49 | 50 | const QString& Compiler::getInterpreterLocation() const 51 | { 52 | return interpreterLocation; 53 | } 54 | 55 | const QStringList& Compiler::getBytecodeExtensions() const 56 | { 57 | return bytecodeExtensions; 58 | } 59 | 60 | const QStringList& Compiler::getConfigurationNames() const 61 | { 62 | return configurationNames; 63 | } 64 | 65 | const QStringList& Compiler::getCompilerArguments() const 66 | { 67 | return compilerArguments; 68 | } 69 | 70 | const QStringList& Compiler::getInterpreterArguments() const 71 | { 72 | return interpreterArguments; 73 | } 74 | 75 | const QProcessEnvironment& Compiler::getEnvironment() const 76 | { 77 | return environment; 78 | } 79 | 80 | double Compiler::getTimeLimitRatio() const 81 | { 82 | return timeLimitRatio; 83 | } 84 | 85 | double Compiler::getMemoryLimitRatio() const 86 | { 87 | return memoryLimitRatio; 88 | } 89 | 90 | bool Compiler::getDisableMemoryLimitCheck() const 91 | { 92 | return disableMemoryLimitCheck; 93 | } 94 | 95 | void Compiler::setCompilerType(Compiler::CompilerType type) 96 | { 97 | compilerType = type; 98 | } 99 | 100 | void Compiler::setCompilerName(const QString &name) 101 | { 102 | compilerName = name; 103 | } 104 | 105 | void Compiler::setSourceExtensions(const QString &extensions) 106 | { 107 | sourceExtensions = extensions.split(";", QString::SkipEmptyParts); 108 | } 109 | 110 | void Compiler::setCompilerLocation(const QString &location) 111 | { 112 | compilerLocation = location; 113 | } 114 | 115 | void Compiler::setInterpreterLocation(const QString &location) 116 | { 117 | interpreterLocation = location; 118 | } 119 | 120 | void Compiler::setBytecodeExtensions(const QString &extensions) 121 | { 122 | bytecodeExtensions = extensions.split(";", QString::SkipEmptyParts); 123 | } 124 | 125 | void Compiler::setEnvironment(const QProcessEnvironment &env) 126 | { 127 | environment = env; 128 | } 129 | 130 | void Compiler::setTimeLimitRatio(double ratio) 131 | { 132 | timeLimitRatio = ratio; 133 | } 134 | 135 | void Compiler::setMemoryLimitRatio(double ratio) 136 | { 137 | memoryLimitRatio = ratio; 138 | } 139 | 140 | void Compiler::setDisableMemoryLimitCheck(bool check) 141 | { 142 | disableMemoryLimitCheck = check; 143 | } 144 | 145 | void Compiler::addConfiguration(const QString &name, const QString &arguments1, const QString &arguments2) 146 | { 147 | configurationNames.append(name); 148 | compilerArguments.append(arguments1); 149 | interpreterArguments.append(arguments2); 150 | } 151 | 152 | void Compiler::setConfigName(int index, const QString &name) 153 | { 154 | if (0 <= index && index < configurationNames.size()) { 155 | configurationNames[index] = name; 156 | } 157 | } 158 | 159 | void Compiler::setCompilerArguments(int index, const QString &arguments) 160 | { 161 | if (0 <= index && index < compilerArguments.size()) { 162 | compilerArguments[index] = arguments; 163 | } 164 | } 165 | 166 | void Compiler::setInterpreterArguments(int index, const QString &arguments) 167 | { 168 | if (0 <= index && index < interpreterArguments.size()) { 169 | interpreterArguments[index] = arguments; 170 | } 171 | } 172 | 173 | void Compiler::deleteConfiguration(int index) 174 | { 175 | if (0 <= index && index < configurationNames.size()) { 176 | configurationNames.removeAt(index); 177 | compilerArguments.removeAt(index); 178 | interpreterArguments.removeAt(index); 179 | } 180 | } 181 | 182 | void Compiler::copyFrom(Compiler *other) 183 | { 184 | compilerType = other->getCompilerType(); 185 | compilerName = other->getCompilerName(); 186 | sourceExtensions = other->getSourceExtensions(); 187 | compilerLocation = other->getCompilerLocation(); 188 | interpreterLocation = other->getInterpreterLocation(); 189 | bytecodeExtensions = other->getBytecodeExtensions(); 190 | configurationNames = other->getConfigurationNames(); 191 | compilerArguments = other->getCompilerArguments(); 192 | interpreterArguments = other->getInterpreterArguments(); 193 | environment = other->getEnvironment(); 194 | timeLimitRatio = other->getTimeLimitRatio(); 195 | memoryLimitRatio = other->getMemoryLimitRatio(); 196 | disableMemoryLimitCheck = other->getDisableMemoryLimitCheck(); 197 | } 198 | -------------------------------------------------------------------------------- /compiler.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef COMPILER_H 20 | #define COMPILER_H 21 | 22 | #include 23 | #include 24 | 25 | class Compiler : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | enum CompilerType { Typical, InterpretiveWithByteCode, InterpretiveWithoutByteCode }; 30 | 31 | explicit Compiler(QObject *parent = 0); 32 | 33 | CompilerType getCompilerType() const; 34 | const QString& getCompilerName() const; 35 | const QStringList& getSourceExtensions() const; 36 | const QString& getCompilerLocation() const; 37 | const QString& getInterpreterLocation() const; 38 | const QStringList& getBytecodeExtensions() const; 39 | const QStringList& getConfigurationNames() const; 40 | const QStringList& getCompilerArguments() const; 41 | const QStringList& getInterpreterArguments() const; 42 | const QProcessEnvironment& getEnvironment() const; 43 | double getTimeLimitRatio() const; 44 | double getMemoryLimitRatio() const; 45 | bool getDisableMemoryLimitCheck() const; 46 | 47 | void setCompilerType(CompilerType); 48 | void setCompilerName(const QString&); 49 | void setSourceExtensions(const QString&); 50 | void setCompilerLocation(const QString&); 51 | void setInterpreterLocation(const QString&); 52 | void setBytecodeExtensions(const QString&); 53 | void setEnvironment(const QProcessEnvironment&); 54 | void setTimeLimitRatio(double); 55 | void setMemoryLimitRatio(double); 56 | void setDisableMemoryLimitCheck(bool); 57 | 58 | void addConfiguration(const QString&, const QString&, const QString&); 59 | void setConfigName(int, const QString&); 60 | void setCompilerArguments(int, const QString&); 61 | void setInterpreterArguments(int, const QString&); 62 | void deleteConfiguration(int); 63 | 64 | void copyFrom(Compiler*); 65 | 66 | private: 67 | CompilerType compilerType; 68 | QString compilerName; 69 | QStringList sourceExtensions; 70 | QString compilerLocation; 71 | QString interpreterLocation; 72 | QStringList bytecodeExtensions; 73 | QStringList configurationNames; 74 | QStringList compilerArguments; 75 | QStringList interpreterArguments; 76 | QProcessEnvironment environment; 77 | double timeLimitRatio; 78 | double memoryLimitRatio; 79 | bool disableMemoryLimitCheck; 80 | }; 81 | 82 | #endif // COMPILER_H 83 | -------------------------------------------------------------------------------- /compilersettings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef COMPILERSETTINGS_H 21 | #define COMPILERSETTINGS_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ui { 29 | class CompilerSettings; 30 | } 31 | 32 | class Settings; 33 | class Compiler; 34 | 35 | class CompilerSettings : public QWidget 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit CompilerSettings(QWidget *parent = 0); 41 | ~CompilerSettings(); 42 | void resetEditSettings(Settings*); 43 | bool checkValid(); 44 | 45 | private: 46 | Ui::CompilerSettings *ui; 47 | Settings *editSettings; 48 | Compiler *curCompiler; 49 | QAction *deleteCompilerKeyAction; 50 | void setCurrentCompiler(Compiler*); 51 | void refreshItemState(); 52 | 53 | private slots: 54 | void moveUpCompiler(); 55 | void moveDownCompiler(); 56 | void addCompiler(); 57 | void deleteCompiler(); 58 | void compilerNameChanged(const QString&); 59 | void sourceExtensionsChanged(const QString&); 60 | void compilerListCurrentRowChanged(); 61 | void advancedButtonClicked(); 62 | }; 63 | 64 | #endif // COMPILERSETTINGS_H 65 | -------------------------------------------------------------------------------- /contest.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef CONTEST_H 20 | #define CONTEST_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | #define MagicNumber 0x20111127 26 | 27 | class Task; 28 | class Settings; 29 | class Contestant; 30 | 31 | class Contest : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit Contest(QObject *parent = 0); 36 | void setSettings(Settings*); 37 | void setContestTitle(const QString&); 38 | const QString& getContestTitle() const; 39 | Task* getTask(int) const; 40 | const QList& getTaskList() const; 41 | Contestant* getContestant(const QString&) const; 42 | QList getContestantList() const; 43 | int getTotalTimeLimit() const; 44 | void addTask(Task*); 45 | void deleteTask(int); 46 | void refreshContestantList(); 47 | void deleteContestant(const QString&); 48 | void writeToStream(QDataStream&); 49 | void readFromStream(QDataStream&); 50 | 51 | private: 52 | QString contestTitle; 53 | Settings *settings; 54 | QList taskList; 55 | QMap contestantList; 56 | bool stopJudging; 57 | void judge(Contestant*); 58 | void judge(Contestant*, int); 59 | void clearPath(const QString&); 60 | 61 | public slots: 62 | void judge(const QString&); 63 | void judge(const QString&, int); 64 | void judgeAll(); 65 | void stopJudgingSlot(); 66 | 67 | signals: 68 | void taskAddedForContestant(); 69 | void taskDeletedForContestant(int); 70 | void taskAddedForViewer(); 71 | void taskDeletedForViewer(int); 72 | void problemTitleChanged(); 73 | void singleCaseFinished(int, int, int, int); 74 | void taskJudgingStarted(QString); 75 | void taskJudgingFinished(); 76 | void contestantJudgingStart(QString); 77 | void contestantJudgingFinished(); 78 | void compileError(int, int); 79 | void stopJudgingSignal(); 80 | }; 81 | 82 | #endif // CONTEST_H 83 | -------------------------------------------------------------------------------- /contestant.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef CONTESTANT_H 20 | #define CONTESTANT_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Contestant : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit Contestant(QObject *parent = 0); 31 | 32 | const QString& getContestantName() const; 33 | bool getCheckJudged(int) const; 34 | CompileState getCompileState(int) const; 35 | const QString& getSourceFile(int) const; 36 | const QString& getCompileMessage(int) const; 37 | const QList& getInputFiles(int) const; 38 | const QList< QList >& getResult(int) const; 39 | const QList& getMessage(int) const; 40 | const QList< QList >& getSocre(int) const; 41 | const QList< QList >& getTimeUsed(int) const; 42 | const QList< QList >& getMemoryUsed(int) const; 43 | QDateTime getJudingTime() const; 44 | int getTaskScore(int) const; 45 | int getTotalScore() const; 46 | int getTotalUsedTime() const; 47 | 48 | void setContestantName(const QString&); 49 | void setCheckJudged(int, bool); 50 | void setCompileState(int, CompileState); 51 | void setSourceFile(int, const QString&); 52 | void setCompileMessage(int, const QString&); 53 | void setInputFiles(int, const QList&); 54 | void setResult(int, const QList< QList >&); 55 | void setMessage(int, const QList&); 56 | void setScore(int, const QList< QList >&); 57 | void setTimeUsed(int, const QList< QList >&); 58 | void setMemoryUsed(int, const QList< QList >&); 59 | void setJudgingTime(QDateTime); 60 | 61 | void writeToStream(QDataStream&); 62 | void readFromStream(QDataStream&); 63 | 64 | private: 65 | QString contestantName; 66 | QList checkJudged; 67 | QList compileState; 68 | QStringList sourceFile; 69 | QStringList compileMesaage; 70 | QList< QList > inputFiles; 71 | QList< QList< QList > > result; 72 | QList< QList > message; 73 | QList< QList< QList > > score; 74 | QList< QList< QList > > timeUsed; 75 | QList< QList< QList > > memoryUsed; 76 | QDateTime judgingTime; 77 | 78 | signals: 79 | 80 | public slots: 81 | void addTask(); 82 | void deleteTask(int); 83 | }; 84 | 85 | #endif // CONTESTANT_H 86 | -------------------------------------------------------------------------------- /core.pro: -------------------------------------------------------------------------------- 1 | # 2 | # Project Lemon - A tiny judging environment for OI contest 3 | # Copyright (C) 2011 Zhipeng Jia 4 | # Copyright (C) 2016 Menci 5 | # Copyright (C) 2019 WAAutoMaton 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | QT += core gui network widgets 22 | 23 | TARGET = Lemon 24 | TEMPLATE = app 25 | 26 | SOURCES += main.cpp \ 27 | lemon.cpp \ 28 | contest.cpp \ 29 | task.cpp \ 30 | testcase.cpp \ 31 | settings.cpp \ 32 | compiler.cpp \ 33 | filelineedit.cpp \ 34 | summarytree.cpp \ 35 | taskeditwidget.cpp \ 36 | testcaseeditwidget.cpp \ 37 | generalsettings.cpp \ 38 | compilersettings.cpp \ 39 | addtestcaseswizard.cpp \ 40 | contestant.cpp \ 41 | judgingdialog.cpp \ 42 | judgingthread.cpp \ 43 | optionsdialog.cpp \ 44 | resultviewer.cpp \ 45 | assignmentthread.cpp \ 46 | detaildialog.cpp \ 47 | newcontestwidget.cpp \ 48 | opencontestwidget.cpp \ 49 | newcontestdialog.cpp \ 50 | opencontestdialog.cpp \ 51 | welcomedialog.cpp \ 52 | addtaskdialog.cpp \ 53 | qtlockedfile/qtlockedfile.cpp \ 54 | qtsingleapplication/qtsinglecoreapplication.cpp \ 55 | qtsingleapplication/qtsingleapplication.cpp \ 56 | qtsingleapplication/qtlocalpeer.cpp \ 57 | advancedcompilersettingsdialog.cpp \ 58 | environmentvariablesdialog.cpp \ 59 | editvariabledialog.cpp \ 60 | addcompilerwizard.cpp \ 61 | selftestutil.cpp \ 62 | exportutil.cpp 63 | 64 | win32:SOURCES += qtlockedfile/qtlockedfile_win.cpp 65 | unix:SOURCES += qtlockedfile/qtlockedfile_unix.cpp 66 | 67 | HEADERS += lemon.h \ 68 | contest.h \ 69 | task.h \ 70 | testcase.h \ 71 | settings.h \ 72 | compiler.h \ 73 | filelineedit.h \ 74 | summarytree.h \ 75 | taskeditwidget.h \ 76 | testcaseeditwidget.h \ 77 | generalsettings.h \ 78 | compilersettings.h \ 79 | addtestcaseswizard.h \ 80 | contestant.h \ 81 | judgingdialog.h \ 82 | judgingthread.h \ 83 | optionsdialog.h \ 84 | resultviewer.h \ 85 | assignmentthread.h \ 86 | globaltype.h \ 87 | detaildialog.h \ 88 | newcontestwidget.h \ 89 | opencontestwidget.h \ 90 | newcontestdialog.h \ 91 | opencontestdialog.h \ 92 | welcomedialog.h \ 93 | addtaskdialog.h \ 94 | qtlockedfile/qtlockedfile.h \ 95 | qtsingleapplication/qtsinglecoreapplication.h \ 96 | qtsingleapplication/qtsingleapplication.h \ 97 | qtsingleapplication/qtlocalpeer.h \ 98 | advancedcompilersettingsdialog.h \ 99 | environmentvariablesdialog.h \ 100 | editvariabledialog.h \ 101 | addcompilerwizard.h \ 102 | selftestutil.h \ 103 | exportutil.h 104 | 105 | win32:FORMS += forms_win32/lemon.ui \ 106 | forms_win32/taskeditwidget.ui \ 107 | forms_win32/testcaseeditwidget.ui \ 108 | forms_win32/generalsettings.ui \ 109 | forms_win32/compilersettings.ui \ 110 | forms_win32/addtestcaseswizard.ui \ 111 | forms_win32/judgingdialog.ui \ 112 | forms_win32/optionsdialog.ui \ 113 | forms_win32/detaildialog.ui \ 114 | forms_win32/newcontestwidget.ui \ 115 | forms_win32/opencontestwidget.ui \ 116 | forms_win32/newcontestdialog.ui \ 117 | forms_win32/opencontestdialog.ui \ 118 | forms_win32/welcomedialog.ui \ 119 | forms_win32/addtaskdialog.ui \ 120 | forms_win32/advancedcompilersettingsdialog.ui \ 121 | forms_win32/environmentvariablesdialog.ui \ 122 | forms_win32/editvariabledialog.ui \ 123 | forms_win32/addcompilerwizard.ui 124 | 125 | unix:FORMS += forms_unix/lemon.ui \ 126 | forms_unix/taskeditwidget.ui \ 127 | forms_unix/testcaseeditwidget.ui \ 128 | forms_unix/generalsettings.ui \ 129 | forms_unix/compilersettings.ui \ 130 | forms_unix/addtestcaseswizard.ui \ 131 | forms_unix/judgingdialog.ui \ 132 | forms_unix/optionsdialog.ui \ 133 | forms_unix/detaildialog.ui \ 134 | forms_unix/newcontestwidget.ui \ 135 | forms_unix/opencontestwidget.ui \ 136 | forms_unix/newcontestdialog.ui \ 137 | forms_unix/opencontestdialog.ui \ 138 | forms_unix/welcomedialog.ui \ 139 | forms_unix/addtaskdialog.ui \ 140 | forms_unix/advancedcompilersettingsdialog.ui \ 141 | forms_unix/environmentvariablesdialog.ui \ 142 | forms_unix/editvariabledialog.ui \ 143 | forms_unix/addcompilerwizard.ui 144 | 145 | TRANSLATIONS += Lemon_zh_CN.ts 146 | 147 | win32:RC_FILE = Lemon.rc 148 | 149 | win32:LIBS += -lpsapi 150 | 151 | win32:CONFIG += qaxcontainer 152 | 153 | RESOURCES += resource.qrc 154 | 155 | CONFIG += debug_and_release 156 | 157 | ICON = icon.icns 158 | 159 | TRANSLATIONS_FILES = 160 | 161 | qtPrepareTool(LRELEASE, lrelease) 162 | for(tsfile, TRANSLATIONS) { 163 | qmfile = $$shadowed($$tsfile) 164 | qmfile ~= s,.ts$,.qm, 165 | qmdir = $$dirname(qmfile) 166 | !exists($$qmdir) { 167 | mkpath($$qmdir)|error("Aborting.") 168 | } 169 | command = $$LRELEASE -removeidentical $$tsfile -qm $$qmfile 170 | system($$command)|error("Failed to run: $$command") 171 | TRANSLATIONS_FILES += $$qmfile 172 | } 173 | -------------------------------------------------------------------------------- /cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/cross.png -------------------------------------------------------------------------------- /crossplatformhelper.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2016 Menci 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifdef __APPLE__ 20 | # define LEMON_OS_OSX 21 | # define LEMON_OS_UNIX 22 | #elif __linux__ 23 | # define LEMON_OS_LINUX 24 | # define LEMON_OS_UNIX 25 | #elif _WIN32 26 | # define LEMON_OS_WIN32 27 | #endif 28 | -------------------------------------------------------------------------------- /detaildialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef DETAILDIALOG_H 21 | #define DETAILDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class Contestant; 29 | class Contest; 30 | 31 | namespace Ui { 32 | class DetailDialog; 33 | } 34 | 35 | class DetailDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit DetailDialog(QWidget *parent = 0); 41 | ~DetailDialog(); 42 | void refreshViewer(Contest*, Contestant*); 43 | void showDialog(); 44 | 45 | private: 46 | Ui::DetailDialog *ui; 47 | Contest *contest; 48 | Contestant *contestant; 49 | 50 | private slots: 51 | void anchorClicked(const QUrl&); 52 | 53 | signals: 54 | void rejudgeSignal(); 55 | }; 56 | 57 | #endif // DETAILDIALOG_H 58 | -------------------------------------------------------------------------------- /downarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/downarrow.png -------------------------------------------------------------------------------- /editvariabledialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "editvariabledialog.h" 20 | #include "ui_editvariabledialog.h" 21 | 22 | EditVariableDialog::EditVariableDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::EditVariableDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | 29 | connect(ui->variableName, SIGNAL(textChanged(QString)), 30 | this, SLOT(textChanged())); 31 | connect(ui->variableValue, SIGNAL(textChanged(QString)), 32 | this, SLOT(textChanged())); 33 | } 34 | 35 | EditVariableDialog::~EditVariableDialog() 36 | { 37 | delete ui; 38 | } 39 | 40 | void EditVariableDialog::setVariableName(const QString &variable) 41 | { 42 | ui->variableName->setText(variable); 43 | } 44 | 45 | void EditVariableDialog::setVariableValue(const QString &value) 46 | { 47 | ui->variableValue->setText(value); 48 | } 49 | 50 | QString EditVariableDialog::getVariableName() const 51 | { 52 | return ui->variableName->text(); 53 | } 54 | 55 | QString EditVariableDialog::getVariableValue() const 56 | { 57 | return ui->variableValue->text(); 58 | } 59 | 60 | void EditVariableDialog::textChanged() 61 | { 62 | if (! ui->variableName->text().isEmpty() && ! ui->variableValue->text().isEmpty()) { 63 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 64 | } else { 65 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /editvariabledialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef EDITVARIABLEDIALOG_H 21 | #define EDITVARIABLEDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ui { 29 | class EditVariableDialog; 30 | } 31 | 32 | class EditVariableDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit EditVariableDialog(QWidget *parent = 0); 38 | ~EditVariableDialog(); 39 | void setVariableName(const QString&); 40 | void setVariableValue(const QString&); 41 | QString getVariableName() const; 42 | QString getVariableValue() const; 43 | 44 | private: 45 | Ui::EditVariableDialog *ui; 46 | 47 | private slots: 48 | void textChanged(); 49 | }; 50 | 51 | #endif // EDITVARIABLEDIALOG_H 52 | -------------------------------------------------------------------------------- /environmentvariablesdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "environmentvariablesdialog.h" 20 | #include "ui_environmentvariablesdialog.h" 21 | #include "editvariabledialog.h" 22 | 23 | EnvironmentVariablesDialog::EnvironmentVariablesDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::EnvironmentVariablesDialog) 26 | { 27 | ui->setupUi(this); 28 | 29 | connect(ui->addButton, SIGNAL(clicked()), 30 | this, SLOT(addButtonClicked())); 31 | connect(ui->editButton, SIGNAL(clicked()), 32 | this, SLOT(editButtonClicked())); 33 | connect(ui->deleteButton, SIGNAL(clicked()), 34 | this, SLOT(deleteButtonClicked())); 35 | connect(ui->valueViewer, SIGNAL(itemSelectionChanged()), 36 | this, SLOT(viewerSelectionChanged())); 37 | } 38 | 39 | EnvironmentVariablesDialog::~EnvironmentVariablesDialog() 40 | { 41 | delete ui; 42 | } 43 | 44 | void EnvironmentVariablesDialog::setProcessEnvironment(const QProcessEnvironment &environment) 45 | { 46 | QStringList values = environment.toStringList(); 47 | ui->valueViewer->setRowCount(values.size()); 48 | for (int i = 0; i < values.size(); i ++) { 49 | int tmp = values[i].indexOf('='); 50 | QString variable = values[i].mid(0, tmp); 51 | QString value = values[i].mid(tmp + 1); 52 | ui->valueViewer->setItem(i, 0, new QTableWidgetItem(variable)); 53 | ui->valueViewer->setItem(i, 1, new QTableWidgetItem(value)); 54 | } 55 | } 56 | 57 | QProcessEnvironment EnvironmentVariablesDialog::getProcessEnvironment() const 58 | { 59 | QProcessEnvironment environment; 60 | for (int i = 0; i < ui->valueViewer->rowCount(); i ++) { 61 | QString variable = ui->valueViewer->item(i, 0)->text(); 62 | QString value = ui->valueViewer->item(i, 1)->text(); 63 | environment.insert(variable, value); 64 | } 65 | return environment; 66 | } 67 | 68 | void EnvironmentVariablesDialog::addButtonClicked() 69 | { 70 | EditVariableDialog *dialog = new EditVariableDialog(this); 71 | dialog->setWindowTitle(tr("Add New Variable")); 72 | if (dialog->exec() == QDialog::Accepted) { 73 | ui->valueViewer->setRowCount(ui->valueViewer->rowCount() + 1); 74 | ui->valueViewer->setItem(ui->valueViewer->rowCount() - 1, 0, 75 | new QTableWidgetItem(dialog->getVariableName())); 76 | ui->valueViewer->setItem(ui->valueViewer->rowCount() - 1, 1, 77 | new QTableWidgetItem(dialog->getVariableValue())); 78 | } 79 | delete dialog; 80 | } 81 | 82 | void EnvironmentVariablesDialog::editButtonClicked() 83 | { 84 | int index = ui->valueViewer->currentRow(); 85 | EditVariableDialog *dialog = new EditVariableDialog(this); 86 | dialog->setWindowTitle(tr("Edit Variable")); 87 | dialog->setVariableName(ui->valueViewer->item(index, 0)->text()); 88 | dialog->setVariableValue(ui->valueViewer->item(index, 1)->text()); 89 | if (dialog->exec() == QDialog::Accepted) { 90 | ui->valueViewer->setItem(index, 0, new QTableWidgetItem(dialog->getVariableName())); 91 | ui->valueViewer->setItem(index, 1, new QTableWidgetItem(dialog->getVariableValue())); 92 | } 93 | delete dialog; 94 | } 95 | 96 | void EnvironmentVariablesDialog::deleteButtonClicked() 97 | { 98 | int index = ui->valueViewer->currentRow(); 99 | QString variable = ui->valueViewer->item(index, 0)->text(); 100 | 101 | if (QMessageBox::question(this, tr("Lemon"), tr("Are you sure to delete variable %1?").arg(variable), 102 | QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) { 103 | return; 104 | } 105 | 106 | for (int i = index + 1; i < ui->valueViewer->rowCount(); i ++) { 107 | ui->valueViewer->setItem(i - 1, 0, new QTableWidgetItem(ui->valueViewer->item(i, 0)->text())); 108 | ui->valueViewer->setItem(i - 1, 1, new QTableWidgetItem(ui->valueViewer->item(i, 1)->text())); 109 | } 110 | ui->valueViewer->setRowCount(ui->valueViewer->rowCount() - 1); 111 | } 112 | 113 | void EnvironmentVariablesDialog::viewerSelectionChanged() 114 | { 115 | QList range = ui->valueViewer->selectedRanges(); 116 | if (range.size() > 0) { 117 | ui->editButton->setEnabled(true); 118 | ui->deleteButton->setEnabled(true); 119 | } else { 120 | ui->editButton->setEnabled(false); 121 | ui->deleteButton->setEnabled(false); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /environmentvariablesdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef ENVIRONMENTVARIABLESDIALOG_H 21 | #define ENVIRONMENTVARIABLESDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ui { 29 | class EnvironmentVariablesDialog; 30 | } 31 | 32 | class EnvironmentVariablesDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit EnvironmentVariablesDialog(QWidget *parent = 0); 38 | ~EnvironmentVariablesDialog(); 39 | void setProcessEnvironment(const QProcessEnvironment&); 40 | QProcessEnvironment getProcessEnvironment() const; 41 | 42 | private: 43 | Ui::EnvironmentVariablesDialog *ui; 44 | 45 | private slots: 46 | void addButtonClicked(); 47 | void editButtonClicked(); 48 | void deleteButtonClicked(); 49 | void viewerSelectionChanged(); 50 | }; 51 | 52 | #endif // ENVIRONMENTVARIABLESDIALOG_H 53 | -------------------------------------------------------------------------------- /exportutil.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef EXPORTUTIL_H 21 | #define EXPORTUTIL_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef Q_OS_WIN32 31 | #include 32 | #endif 33 | 34 | class Contest; 35 | class Contestant; 36 | 37 | class ExportUtil : public QObject 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit ExportUtil(QObject *parent = 0); 42 | static void exportResult(QWidget*, Contest*); 43 | 44 | private: 45 | static QString getContestantHtmlCode(Contest*, Contestant*); 46 | static void exportHtml(QWidget*, Contest*, const QString&); 47 | static void exportCsv(QWidget*, Contest*, const QString&); 48 | static void exportXls(QWidget*, Contest*, const QString&); 49 | 50 | signals: 51 | 52 | public slots: 53 | 54 | }; 55 | 56 | #endif // EXPORTUTIL_H 57 | -------------------------------------------------------------------------------- /filelineedit.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "filelineedit.h" 20 | #include "settings.h" 21 | 22 | FileLineEdit::FileLineEdit(QWidget *parent) : 23 | QLineEdit(parent) 24 | { 25 | completer = 0; 26 | } 27 | 28 | void FileLineEdit::getFiles(const QString &curDir, const QString &prefix, QStringList &files) 29 | { 30 | QDir dir(curDir); 31 | if (! nameFilters.isEmpty()) { 32 | dir.setNameFilters(nameFilters); 33 | } 34 | QStringList list = dir.entryList(filters); 35 | for (int i = 0; i < list.size(); i ++) { 36 | list[i] = prefix + list[i]; 37 | } 38 | files.append(list); 39 | list = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); 40 | for (int i = 0; i < list.size(); i ++) { 41 | getFiles(curDir + list[i] + QDir::separator(), 42 | prefix + list[i] + QDir::separator(), files); 43 | } 44 | } 45 | 46 | void FileLineEdit::setFilters(QDir::Filters _filters) 47 | { 48 | filters = _filters; 49 | } 50 | 51 | void FileLineEdit::setFileExtensions(const QStringList &extensions) 52 | { 53 | nameFilters.clear(); 54 | for (int i = 0; i < extensions.size(); i ++) { 55 | nameFilters.append("*." + extensions[i]); 56 | } 57 | refreshFileList(); 58 | } 59 | 60 | void FileLineEdit::refreshFileList() 61 | { 62 | QStringList files; 63 | getFiles(Settings::dataPath(), "", files); 64 | if (completer) delete completer; 65 | completer = new QCompleter(files, this); 66 | setCompleter(completer); 67 | } 68 | -------------------------------------------------------------------------------- /filelineedit.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef FILELINEEDIT_H 21 | #define FILELINEEDIT_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class FileLineEdit : public QLineEdit 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit FileLineEdit(QWidget *parent = 0); 33 | void setFilters(QDir::Filters); 34 | void setFileExtensions(const QStringList&); 35 | void getFiles(const QString&, const QString&, QStringList&); 36 | 37 | private: 38 | QCompleter *completer; 39 | QStringList nameFilters; 40 | QDir::Filters filters; 41 | 42 | public slots: 43 | void refreshFileList(); 44 | }; 45 | 46 | #endif // FILELINEEDIT_H 47 | -------------------------------------------------------------------------------- /forms_unix/detaildialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DetailDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 709 10 | 520 11 | 12 | 13 | 14 | Details 15 | 16 | 17 | 18 | 19 | 20 | Qt::LinksAccessibleByMouse 21 | 22 | 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | &Close 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | closeButton 57 | clicked() 58 | DetailDialog 59 | accept() 60 | 61 | 62 | 650 63 | 493 64 | 65 | 66 | 354 67 | 259 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /forms_unix/editvariabledialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditVariableDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 325 10 | 128 11 | 12 | 13 | 14 | 15 | 325 16 | 128 17 | 18 | 19 | 20 | 21 | 325 22 | 128 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 8 31 | 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 8 39 | 40 | 41 | 42 | 43 | font-size:11pt; 44 | 45 | 46 | Variable Name 47 | 48 | 49 | 50 | 51 | 52 | 53 | font-size:11pt; 54 | 55 | 56 | 57 | 58 | 59 | 60 | font-size:11pt; 61 | 62 | 63 | Variable Value 64 | 65 | 66 | 67 | 68 | 69 | 70 | font-size:11pt; 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | font-size:10pt; 80 | 81 | 82 | Qt::Horizontal 83 | 84 | 85 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | buttonBox 95 | accepted() 96 | EditVariableDialog 97 | accept() 98 | 99 | 100 | 248 101 | 254 102 | 103 | 104 | 157 105 | 274 106 | 107 | 108 | 109 | 110 | buttonBox 111 | rejected() 112 | EditVariableDialog 113 | reject() 114 | 115 | 116 | 316 117 | 260 118 | 119 | 120 | 286 121 | 274 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /forms_unix/environmentvariablesdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnvironmentVariablesDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 298 10 | 196 11 | 12 | 13 | 14 | 15 | 298 16 | 196 17 | 18 | 19 | 20 | Extra Environment Variables 21 | 22 | 23 | 24 | 8 25 | 26 | 27 | 28 | 29 | font-size: 11pt; 30 | 31 | 32 | QAbstractItemView::NoEditTriggers 33 | 34 | 35 | QAbstractItemView::SingleSelection 36 | 37 | 38 | QAbstractItemView::SelectRows 39 | 40 | 41 | 80 42 | 43 | 44 | false 45 | 46 | 47 | true 48 | 49 | 50 | false 51 | 52 | 53 | 25 54 | 55 | 56 | 25 57 | 58 | 59 | 60 | Variable 61 | 62 | 63 | 64 | 65 | Value 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Qt::Horizontal 76 | 77 | 78 | 79 | 40 80 | 20 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | &Add 89 | 90 | 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | &Edit 99 | 100 | 101 | 102 | 103 | 104 | 105 | false 106 | 107 | 108 | &Delete 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | font-size:10pt; 118 | 119 | 120 | Qt::Horizontal 121 | 122 | 123 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | buttonBox 133 | accepted() 134 | EnvironmentVariablesDialog 135 | accept() 136 | 137 | 138 | 248 139 | 254 140 | 141 | 142 | 157 143 | 274 144 | 145 | 146 | 147 | 148 | buttonBox 149 | rejected() 150 | EnvironmentVariablesDialog 151 | reject() 152 | 153 | 154 | 316 155 | 260 156 | 157 | 158 | 286 159 | 274 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /forms_unix/judgingdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JudgingDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 448 13 | 263 14 | 15 | 16 | 17 | 18 | 448 19 | 263 20 | 21 | 22 | 23 | Judging 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Qt::Horizontal 42 | 43 | 44 | 45 | 40 46 | 20 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Cancel 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /forms_unix/newcontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | New Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:10pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | NewContestWidget 41 | QWidget 42 |
newcontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | NewContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | NewContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_unix/newcontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 392 10 | 290 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 12 21 | 22 | 23 | 15 24 | 25 | 26 | 27 | 28 | font-size:11pt;font-weight:bold; 29 | 30 | 31 | Contest Title 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | font-size:11pt;font-weight:bold; 42 | 43 | 44 | Saving Name 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | font-size:11pt;font-weight:bold; 55 | 56 | 57 | Contest Path 58 | 59 | 60 | 61 | 62 | 63 | 64 | 10 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ... 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Qt::Vertical 84 | 85 | 86 | 87 | 20 88 | 168 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /forms_unix/opencontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | Open an Existing Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:10pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | OpenContestWidget 41 | QWidget 42 |
opencontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | OpenContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | OpenContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_unix/opencontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | font-size: 11pt; 21 | 22 | 23 | QAbstractItemView::NoEditTriggers 24 | 25 | 26 | QAbstractItemView::SingleSelection 27 | 28 | 29 | QAbstractItemView::SelectRows 30 | 31 | 32 | false 33 | 34 | 35 | 80 36 | 37 | 38 | true 39 | 40 | 41 | false 42 | 43 | 44 | 25 45 | 46 | 47 | 25 48 | 49 | 50 | 51 | Title 52 | 53 | 54 | 55 | 11 56 | 75 57 | true 58 | 59 | 60 | 61 | 62 | 63 | Location 64 | 65 | 66 | 67 | 11 68 | 75 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 32 95 | 32 96 | 97 | 98 | 99 | 100 | :/icon/add.png:/icon/add.png 101 | 102 | 103 | 104 | 105 | 106 | 107 | false 108 | 109 | 110 | 111 | 32 112 | 32 113 | 114 | 115 | 116 | 117 | :/icon/rod.png:/icon/rod.png 118 | 119 | 120 | 121 | 122 | 123 | 124 | Qt::Vertical 125 | 126 | 127 | 128 | 20 129 | 40 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /forms_unix/optionsdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OptionsDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 362 10 | 437 11 | 12 | 13 | 14 | 15 | 362 16 | 437 17 | 18 | 19 | 20 | Options 21 | 22 | 23 | 24 | 25 | 26 | font-size: 11pt; 27 | 28 | 29 | 0 30 | 31 | 32 | 33 | General 34 | 35 | 36 | 37 | 38 | Compiler 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | font-size:10pt; 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | GeneralSettings 58 | QWidget 59 |
generalsettings.h
60 | 1 61 |
62 | 63 | CompilerSettings 64 | QWidget 65 |
compilersettings.h
66 | 1 67 |
68 |
69 | 70 | tabWidget 71 | 72 | 73 | 74 | 75 | buttonBox 76 | rejected() 77 | OptionsDialog 78 | reject() 79 | 80 | 81 | 176 82 | 414 83 | 84 | 85 | 176 86 | 219 87 | 88 | 89 | 90 | 91 |
92 | -------------------------------------------------------------------------------- /forms_unix/welcomedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WelcomeDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 470 10 | 350 11 | 12 | 13 | 14 | Welcome 15 | 16 | 17 | 18 | 19 | 20 | font-size: 11pt; 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | Open 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | New 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | font-size:10pt; 51 | 52 | 53 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | OpenContestWidget 62 | QWidget 63 |
opencontestwidget.h
64 | 1 65 |
66 | 67 | NewContestWidget 68 | QWidget 69 |
newcontestwidget.h
70 | 1 71 |
72 |
73 | 74 | 75 | 76 | buttonBox 77 | accepted() 78 | WelcomeDialog 79 | accept() 80 | 81 | 82 | 234 83 | 324 84 | 85 | 86 | 234 87 | 174 88 | 89 | 90 | 91 | 92 | buttonBox 93 | rejected() 94 | WelcomeDialog 95 | reject() 96 | 97 | 98 | 234 99 | 324 100 | 101 | 102 | 234 103 | 174 104 | 105 | 106 | 107 | 108 |
109 | -------------------------------------------------------------------------------- /forms_win32/detaildialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DetailDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 709 10 | 520 11 | 12 | 13 | 14 | Details 15 | 16 | 17 | 18 | 19 | 20 | Qt::LinksAccessibleByMouse 21 | 22 | 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | &Close 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | closeButton 57 | clicked() 58 | DetailDialog 59 | accept() 60 | 61 | 62 | 650 63 | 493 64 | 65 | 66 | 354 67 | 259 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /forms_win32/editvariabledialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditVariableDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 321 10 | 106 11 | 12 | 13 | 14 | 15 | 321 16 | 106 17 | 18 | 19 | 20 | 21 | 321 22 | 106 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 8 31 | 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 8 39 | 40 | 41 | 42 | 43 | font-size:9pt; 44 | 45 | 46 | Variable Name 47 | 48 | 49 | 50 | 51 | 52 | 53 | font-size:9pt; 54 | 55 | 56 | 57 | 58 | 59 | 60 | font-size:9pt; 61 | 62 | 63 | Variable Value 64 | 65 | 66 | 67 | 68 | 69 | 70 | font-size:9pt; 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | font-size:9pt; 80 | 81 | 82 | Qt::Horizontal 83 | 84 | 85 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | buttonBox 95 | accepted() 96 | EditVariableDialog 97 | accept() 98 | 99 | 100 | 248 101 | 254 102 | 103 | 104 | 157 105 | 274 106 | 107 | 108 | 109 | 110 | buttonBox 111 | rejected() 112 | EditVariableDialog 113 | reject() 114 | 115 | 116 | 316 117 | 260 118 | 119 | 120 | 286 121 | 274 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /forms_win32/environmentvariablesdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnvironmentVariablesDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 298 10 | 196 11 | 12 | 13 | 14 | 15 | 298 16 | 196 17 | 18 | 19 | 20 | Extra Environment Variables 21 | 22 | 23 | 24 | 8 25 | 26 | 27 | 28 | 29 | font-size: 9pt; 30 | 31 | 32 | QAbstractItemView::NoEditTriggers 33 | 34 | 35 | QAbstractItemView::SingleSelection 36 | 37 | 38 | QAbstractItemView::SelectRows 39 | 40 | 41 | 80 42 | 43 | 44 | false 45 | 46 | 47 | true 48 | 49 | 50 | false 51 | 52 | 53 | 25 54 | 55 | 56 | 25 57 | 58 | 59 | 60 | Variable 61 | 62 | 63 | 64 | 65 | Value 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Qt::Horizontal 76 | 77 | 78 | 79 | 40 80 | 20 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | &Add 89 | 90 | 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | &Edit 99 | 100 | 101 | 102 | 103 | 104 | 105 | false 106 | 107 | 108 | &Delete 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | font-size:9pt; 118 | 119 | 120 | Qt::Horizontal 121 | 122 | 123 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | buttonBox 133 | accepted() 134 | EnvironmentVariablesDialog 135 | accept() 136 | 137 | 138 | 248 139 | 254 140 | 141 | 142 | 157 143 | 274 144 | 145 | 146 | 147 | 148 | buttonBox 149 | rejected() 150 | EnvironmentVariablesDialog 151 | reject() 152 | 153 | 154 | 316 155 | 260 156 | 157 | 158 | 286 159 | 274 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /forms_win32/judgingdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JudgingDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 448 13 | 263 14 | 15 | 16 | 17 | 18 | 448 19 | 263 20 | 21 | 22 | 23 | Judging 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Qt::Horizontal 42 | 43 | 44 | 45 | 40 46 | 20 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Cancel 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /forms_win32/newcontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | New Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:9pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | NewContestWidget 41 | QWidget 42 |
newcontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | NewContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | NewContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_win32/newcontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 392 10 | 290 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 12 21 | 22 | 23 | 15 24 | 25 | 26 | 27 | 28 | font-size:10pt;font-weight:bold; 29 | 30 | 31 | Contest Title 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | font-size:10pt;font-weight:bold; 42 | 43 | 44 | Saving Name 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | font-size:10pt;font-weight:bold; 55 | 56 | 57 | Contest Path 58 | 59 | 60 | 61 | 62 | 63 | 64 | 10 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ... 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Qt::Vertical 84 | 85 | 86 | 87 | 20 88 | 168 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /forms_win32/opencontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | Open an Existing Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:9pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | OpenContestWidget 41 | QWidget 42 |
opencontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | OpenContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | OpenContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_win32/opencontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | font-size: 9pt; 21 | 22 | 23 | QAbstractItemView::NoEditTriggers 24 | 25 | 26 | QAbstractItemView::SingleSelection 27 | 28 | 29 | QAbstractItemView::SelectRows 30 | 31 | 32 | false 33 | 34 | 35 | 80 36 | 37 | 38 | true 39 | 40 | 41 | false 42 | 43 | 44 | 25 45 | 46 | 47 | 25 48 | 49 | 50 | 51 | Title 52 | 53 | 54 | 55 | 9 56 | 75 57 | true 58 | 59 | 60 | 61 | 62 | 63 | Location 64 | 65 | 66 | 67 | 9 68 | 75 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 27 95 | 27 96 | 97 | 98 | 99 | 100 | :/icon/add.png:/icon/add.png 101 | 102 | 103 | 104 | 105 | 106 | 107 | false 108 | 109 | 110 | 111 | 27 112 | 27 113 | 114 | 115 | 116 | 117 | :/icon/rod.png:/icon/rod.png 118 | 119 | 120 | 121 | 122 | 123 | 124 | Qt::Vertical 125 | 126 | 127 | 128 | 20 129 | 40 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /forms_win32/optionsdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OptionsDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 291 10 | 377 11 | 12 | 13 | 14 | 15 | 291 16 | 377 17 | 18 | 19 | 20 | Options 21 | 22 | 23 | 24 | 25 | 26 | font-size: 9pt; 27 | 28 | 29 | 0 30 | 31 | 32 | 33 | General 34 | 35 | 36 | 37 | 38 | Compiler 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | font-size:9pt; 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | GeneralSettings 58 | QWidget 59 |
generalsettings.h
60 | 1 61 |
62 | 63 | CompilerSettings 64 | QWidget 65 |
compilersettings.h
66 | 1 67 |
68 |
69 | 70 | tabWidget 71 | 72 | 73 | 74 | 75 | buttonBox 76 | rejected() 77 | OptionsDialog 78 | reject() 79 | 80 | 81 | 176 82 | 414 83 | 84 | 85 | 176 86 | 219 87 | 88 | 89 | 90 | 91 |
92 | -------------------------------------------------------------------------------- /forms_win32/welcomedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WelcomeDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 470 10 | 350 11 | 12 | 13 | 14 | Welcome 15 | 16 | 17 | 18 | 19 | 20 | font-size: 9pt; 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | Open 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | New 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | font-size:9pt; 51 | 52 | 53 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | OpenContestWidget 62 | QWidget 63 |
opencontestwidget.h
64 | 1 65 |
66 | 67 | NewContestWidget 68 | QWidget 69 |
newcontestwidget.h
70 | 1 71 |
72 |
73 | 74 | 75 | 76 | buttonBox 77 | accepted() 78 | WelcomeDialog 79 | accept() 80 | 81 | 82 | 234 83 | 324 84 | 85 | 86 | 234 87 | 174 88 | 89 | 90 | 91 | 92 | buttonBox 93 | rejected() 94 | WelcomeDialog 95 | reject() 96 | 97 | 98 | 234 99 | 324 100 | 101 | 102 | 234 103 | 174 104 | 105 | 106 | 107 | 108 |
109 | -------------------------------------------------------------------------------- /generalsettings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef GENERALSETTINGS_H 21 | #define GENERALSETTINGS_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ui { 29 | class GeneralSettings; 30 | } 31 | 32 | class Settings; 33 | 34 | class GeneralSettings : public QWidget 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit GeneralSettings(QWidget *parent = 0); 40 | ~GeneralSettings(); 41 | void resetEditSettings(Settings*); 42 | bool checkValid(); 43 | 44 | private: 45 | Ui::GeneralSettings *ui; 46 | Settings *editSettings; 47 | 48 | private slots: 49 | void defaultFullScoreChanged(const QString&); 50 | void defaultTimeLimitChanged(const QString&); 51 | void defaultMemoryLimitChanged(const QString&); 52 | void compileTimeLimitChanged(const QString&); 53 | void specialJudgeTimeLimitChanged(const QString&); 54 | void fileSizeLimitChanged(const QString&); 55 | void numberOfThreadsChanged(const QString&); 56 | void inputFileExtensionsChanged(const QString&); 57 | void outputFileExtensionsChanged(const QString&); 58 | }; 59 | 60 | #endif // GENERALSETTINGS_H 61 | -------------------------------------------------------------------------------- /globaltype.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef GLOBALTYPE_H 20 | #define GLOBALTYPE_H 21 | 22 | enum CompileState { CompileSuccessfully, NoValidSourceFile, CompileError, 23 | CompileTimeLimitExceeded, InvalidCompiler }; 24 | 25 | enum ResultState { CorrectAnswer, WrongAnswer, PartlyCorrect, 26 | TimeLimitExceeded, MemoryLimitExceeded, 27 | CannotStartProgram, FileError, RunTimeError, 28 | InvalidSpecialJudge, SpecialJudgeTimeLimitExceeded, 29 | SpecialJudgeRunTimeError }; 30 | 31 | #endif // GLOBALTYPE_H 32 | -------------------------------------------------------------------------------- /icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/icon.icns -------------------------------------------------------------------------------- /icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/icon.ico -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/icon.png -------------------------------------------------------------------------------- /judge/judge.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += console 3 | CONFIG -= app_bundle 4 | CONFIG -= qt 5 | 6 | SOURCES += \ 7 | realjudge.c 8 | 9 | unix:TARGET = realjudge_linux 10 | 11 | win32:TARGET = readljudge_win32 12 | -------------------------------------------------------------------------------- /judge/realjudge.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include 20 | #include 21 | 22 | int main(int argc, char *argv[]) { 23 | FILE *contestantOutputFile = fopen(argv[1], "r"); 24 | if (contestantOutputFile == NULL) { 25 | printf("Cannot open contestant\'s output file\n"); 26 | return 0; 27 | } 28 | FILE *standardOutputFile = fopen(argv[2], "r"); 29 | if (standardOutputFile == NULL) { 30 | printf("Cannot open standard output file\n"); 31 | fclose(contestantOutputFile); 32 | return 0; 33 | } 34 | 35 | int realPrecision, i; 36 | sscanf(argv[3], "%d", &realPrecision); 37 | double eps = 1; 38 | for (i = 0; i < realPrecision; i ++) 39 | eps *= 0.1; 40 | 41 | double a, b; 42 | while (1) { 43 | int cnt1 = fscanf(contestantOutputFile, "%lf", &a); 44 | int cnt2 = fscanf(standardOutputFile, "%lf", &b); 45 | if (cnt1 == 0) { 46 | printf("Wrong answer\nInvalid characters found\n"); 47 | fclose(contestantOutputFile); 48 | fclose(standardOutputFile); 49 | return 0; 50 | } 51 | if (cnt2 == 0) { 52 | printf("Invalid characters in standard output file\n"); 53 | fclose(contestantOutputFile); 54 | fclose(standardOutputFile); 55 | return 0; 56 | } 57 | if (cnt1 == EOF && cnt2 == EOF) break; 58 | if (cnt1 == EOF && cnt2 == 1) { 59 | printf("Wrong answer\nShorter than standard output\n"); 60 | fclose(contestantOutputFile); 61 | fclose(standardOutputFile); 62 | return 0; 63 | } 64 | if (cnt1 == 1 && cnt2 == EOF) { 65 | printf("Wrong answer\nLonger than standard output\n"); 66 | fclose(contestantOutputFile); 67 | fclose(standardOutputFile); 68 | return 0; 69 | } 70 | if (fabs(a - b) > eps) { 71 | printf("Wrong answer\nRead %.10lf but expect %.10lf\n", a, b); 72 | fclose(contestantOutputFile); 73 | fclose(standardOutputFile); 74 | return 0; 75 | } 76 | } 77 | 78 | printf("Correct answer\n"); 79 | fclose(contestantOutputFile); 80 | fclose(standardOutputFile); 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /judgingdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef JUDGINGDIALOG_H 21 | #define JUDGINGDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "globaltype.h" 28 | 29 | class Contest; 30 | 31 | namespace Ui { 32 | class JudgingDialog; 33 | } 34 | 35 | class JudgingDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit JudgingDialog(QWidget *parent = 0); 41 | ~JudgingDialog(); 42 | void setContest(Contest*); 43 | void judge(const QStringList&); 44 | void judge(const QString&, int); 45 | void judgeAll(); 46 | void reject(); 47 | 48 | private slots: 49 | void stopJudgingSlot(); 50 | 51 | private: 52 | Ui::JudgingDialog *ui; 53 | Contest *curContest; 54 | QTextCursor *cursor; 55 | bool stopJudging; 56 | 57 | public slots: 58 | void singleCaseFinished(int, int, int, int); 59 | void taskJudgingStarted(const QString&); 60 | void contestantJudgingStart(const QString&); 61 | void contestantJudgingFinished(); 62 | void compileError(int, int); 63 | 64 | signals: 65 | void stopJudgingSignal(); 66 | }; 67 | 68 | #endif // JUDGINGDIALOG_H 69 | -------------------------------------------------------------------------------- /judgingthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef JUDGINGTHREAD_H 20 | #define JUDGINGTHREAD_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Task; 27 | 28 | class JudgingThread : public QThread 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit JudgingThread(QObject *parent = 0); 33 | void setCheckRejudgeMode(bool); 34 | void setExtraTimeRatio(double); 35 | void setEnvironment(const QProcessEnvironment&); 36 | void setWorkingDirectory(const QString&); 37 | void setSpecialJudgeTimeLimit(int); 38 | void setExecutableFile(const QString&); 39 | void setArguments(const QString&); 40 | void setAnswerFile(const QString&); 41 | void setInputFile(const QString&); 42 | void setOutputFile(const QString&); 43 | void setDiffPath(const QString&); 44 | void setTask(Task*); 45 | void setFullScore(int); 46 | void setTimeLimit(int); 47 | void setMemoryLimit(int); 48 | int getTimeUsed() const; 49 | int getMemoryUsed() const; 50 | int getScore() const; 51 | ResultState getResult() const; 52 | const QString& getMessage() const; 53 | bool getNeedRejudge() const; 54 | void run(); 55 | 56 | private: 57 | bool checkRejudgeMode; 58 | bool needRejudge; 59 | double extraTimeRatio; 60 | QProcessEnvironment environment; 61 | QString workingDirectory; 62 | QString executableFile; 63 | QString arguments; 64 | QString answerFile; 65 | QString inputFile; 66 | QString outputFile; 67 | QString diffPath; 68 | Task *task; 69 | int specialJudgeTimeLimit; 70 | int fullScore; 71 | int timeLimit; 72 | int memoryLimit; 73 | int timeUsed; 74 | int memoryUsed; 75 | int score; 76 | ResultState result; 77 | QString message; 78 | bool stopJudging; 79 | void compareLineByLine(const QString&); 80 | void compareIgnoreSpaces(const QString&); 81 | void compareWithDiff(const QString&); 82 | void compareRealNumbers(const QString&); 83 | void specialJudge(const QString&); 84 | void runProgram(); 85 | void judgeOutput(); 86 | void judgeTraditionalTask(); 87 | void judgeAnswersOnlyTask(); 88 | 89 | public slots: 90 | void stopJudgingSlot(); 91 | }; 92 | 93 | #endif // JUDGINGTHREAD_H 94 | -------------------------------------------------------------------------------- /lemon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | Copyright (C) 2019 WAAutoMaton 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | ***************************************************************************/ 20 | 21 | #ifndef LEMON_H 22 | #define LEMON_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Ui { 30 | class Lemon; 31 | } 32 | 33 | class Contest; 34 | class Settings; 35 | class OptionsDialog; 36 | 37 | class Lemon : public QMainWindow 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit Lemon(QWidget *parent = 0); 43 | ~Lemon(); 44 | void changeEvent(QEvent *); 45 | void closeEvent(QCloseEvent *); 46 | void welcome(); 47 | 48 | private: 49 | Ui::Lemon *ui; 50 | Contest *curContest; 51 | Settings *settings; 52 | QFileSystemWatcher *dataDirWatcher; 53 | QString curFile; 54 | QList languageActions; 55 | QTranslator *appTranslator; 56 | QTranslator *qtTranslator; 57 | void loadUiLanguage(); 58 | void insertWatchPath(const QString &, QFileSystemWatcher *); 59 | void newContest(const QString &, const QString &, const QString &); 60 | void saveContest(const QString &); 61 | void loadContest(const QString &); 62 | void getFiles(const QString &, const QStringList &, QMap &); 63 | void addTask(const QString &, const QList> &, int, int, int); 64 | static bool compareFileName(const QPair &, const QPair &); 65 | 66 | private slots: 67 | void summarySelectionChanged(); 68 | void resetDataWatcher(); 69 | void showOptionsDialog(); 70 | void refreshButtonClicked(); 71 | void tabIndexChanged(int); 72 | void viewerSelectionChanged(); 73 | void contestantDeleted(); 74 | void newAction(); 75 | void closeAction(); 76 | void loadAction(); 77 | void addTasksAction(); 78 | void makeSelfTest(); 79 | void exportResult(); 80 | void aboutLemon(); 81 | void setUiLanguage(); 82 | 83 | signals: 84 | void dataPathChanged(); 85 | }; 86 | 87 | #endif // LEMON_H 88 | -------------------------------------------------------------------------------- /lemon.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | core.pro \ 5 | judge/judge.pro 6 | unix:SUBDIRS+=watcher/watcher_unix.pro 7 | -------------------------------------------------------------------------------- /lemon.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icon.ico" 2 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include "qtsingleapplication/qtsingleapplication.h" 22 | #include "lemon.h" 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | QtSingleApplication a(argc, argv); 27 | 28 | if (a.sendMessage("")) { 29 | a.activateWindow(); 30 | return 0; 31 | } 32 | 33 | Lemon w; 34 | a.setActivationWindow(&w); 35 | 36 | w.show(); 37 | w.welcome(); 38 | 39 | return a.exec(); 40 | } 41 | -------------------------------------------------------------------------------- /make: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Project Lemon - A tiny judging environment for OI contest 4 | # Copyright (C) 2016 Menci 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | gcc watcher_unix.c -o watcher_unix 21 | lrelease -verbose Lemon_zh_CN.ts Lemon_zh_CN.qm 22 | qmake 23 | make $1 24 | -------------------------------------------------------------------------------- /newcontestdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "newcontestdialog.h" 20 | #include "ui_newcontestdialog.h" 21 | 22 | NewContestDialog::NewContestDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::NewContestDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->newContestWidget, SIGNAL(informationChanged()), 29 | this, SLOT(informationChanged())); 30 | } 31 | 32 | NewContestDialog::~NewContestDialog() 33 | { 34 | delete ui; 35 | } 36 | 37 | QString NewContestDialog::getContestTitle() 38 | { 39 | return ui->newContestWidget->getContestTitle(); 40 | } 41 | 42 | QString NewContestDialog::getSavingName() 43 | { 44 | return ui->newContestWidget->getSavingName(); 45 | } 46 | 47 | QString NewContestDialog::getContestPath() 48 | { 49 | return ui->newContestWidget->getContestPath(); 50 | } 51 | 52 | void NewContestDialog::informationChanged() 53 | { 54 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 55 | } 56 | -------------------------------------------------------------------------------- /newcontestdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef NEWCONTESTDIALOG_H 20 | #define NEWCONTESTDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class NewContestDialog; 28 | } 29 | 30 | class NewContestDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit NewContestDialog(QWidget *parent = 0); 36 | ~NewContestDialog(); 37 | QString getContestTitle(); 38 | QString getSavingName(); 39 | QString getContestPath(); 40 | 41 | private: 42 | Ui::NewContestDialog *ui; 43 | 44 | private slots: 45 | void informationChanged(); 46 | }; 47 | 48 | #endif // NEWCONTESTDIALOG_H 49 | -------------------------------------------------------------------------------- /newcontestwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "newcontestwidget.h" 20 | #include "ui_newcontestwidget.h" 21 | 22 | NewContestWidget::NewContestWidget(QWidget *parent) : 23 | QWidget(parent), 24 | ui(new Ui::NewContestWidget) 25 | { 26 | ui->setupUi(this); 27 | connect(ui->selectButton, SIGNAL(clicked()), 28 | this, SLOT(selectContestPath())); 29 | connect(ui->savingName, SIGNAL(textChanged(QString)), 30 | this, SLOT(savingNameChanged())); 31 | connect(ui->contestTitle, SIGNAL(textChanged(QString)), 32 | this, SIGNAL(informationChanged())); 33 | connect(ui->savingName, SIGNAL(textChanged(QString)), 34 | this, SIGNAL(informationChanged())); 35 | connect(ui->contestPath, SIGNAL(textChanged(QString)), 36 | this, SIGNAL(informationChanged())); 37 | } 38 | 39 | NewContestWidget::~NewContestWidget() 40 | { 41 | delete ui; 42 | } 43 | 44 | QString NewContestWidget::getContestTitle() 45 | { 46 | return ui->contestTitle->text(); 47 | } 48 | 49 | QString NewContestWidget::getSavingName() 50 | { 51 | return ui->savingName->text(); 52 | } 53 | 54 | QString NewContestWidget::getContestPath() 55 | { 56 | return ui->contestPath->text(); 57 | } 58 | 59 | bool NewContestWidget::checkReady() const 60 | { 61 | return ! ui->contestTitle->text().isEmpty() && ! ui->contestPath->text().isEmpty() && ! ui->savingName->text().isEmpty(); 62 | } 63 | 64 | void NewContestWidget::selectContestPath() 65 | { 66 | QString path = QFileDialog::getExistingDirectory(this, tr("Select Contest Path"), QDir::homePath()); 67 | if (! path.isEmpty()) ui->contestPath->setText(QDir::toNativeSeparators(path)); 68 | } 69 | 70 | void NewContestWidget::savingNameChanged() 71 | { 72 | QString path = QDir::homePath(); 73 | path = QDir::toNativeSeparators(path); 74 | path += QDir::separator(); 75 | path += ui->savingName->text(); 76 | ui->contestPath->setText(path); 77 | } 78 | -------------------------------------------------------------------------------- /newcontestwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef NEWCONTESTWIDGET_H 21 | #define NEWCONTESTWIDGET_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Ui { 30 | class NewContestWidget; 31 | } 32 | 33 | class NewContestWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit NewContestWidget(QWidget *parent = 0); 39 | ~NewContestWidget(); 40 | QString getContestTitle(); 41 | QString getSavingName(); 42 | QString getContestPath(); 43 | bool checkReady() const; 44 | 45 | private: 46 | Ui::NewContestWidget *ui; 47 | 48 | signals: 49 | void informationChanged(); 50 | 51 | private slots: 52 | void selectContestPath(); 53 | void savingNameChanged(); 54 | }; 55 | 56 | #endif // NEWCONTESTWIDGET_H 57 | -------------------------------------------------------------------------------- /opencontestdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "opencontestdialog.h" 20 | #include "ui_opencontestdialog.h" 21 | 22 | OpenContestDialog::OpenContestDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::OpenContestDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->openContestWidget, SIGNAL(selectionChanged()), 29 | this, SLOT(selectionChanged())); 30 | connect(ui->openContestWidget, SIGNAL(rowDoubleClicked()), 31 | this, SLOT(accept())); 32 | } 33 | 34 | OpenContestDialog::~OpenContestDialog() 35 | { 36 | delete ui; 37 | } 38 | 39 | void OpenContestDialog::setRecentContest(const QStringList &list) 40 | { 41 | ui->openContestWidget->setRecentContest(list); 42 | } 43 | 44 | void OpenContestDialog::selectionChanged() 45 | { 46 | if (ui->openContestWidget->getCurrentRow() != -1) { 47 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 48 | } else { 49 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 50 | } 51 | } 52 | 53 | const QStringList& OpenContestDialog::getRecentContest() const 54 | { 55 | return ui->openContestWidget->getRecentContest(); 56 | } 57 | 58 | QString OpenContestDialog::getSelectedContest() 59 | { 60 | return ui->openContestWidget->getRecentContest().at(ui->openContestWidget->getCurrentRow()); 61 | } 62 | -------------------------------------------------------------------------------- /opencontestdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef OPENCONTESTDIALOG_H 20 | #define OPENCONTESTDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class OpenContestDialog; 28 | } 29 | 30 | class OpenContestDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit OpenContestDialog(QWidget *parent = 0); 36 | ~OpenContestDialog(); 37 | void setRecentContest(const QStringList&); 38 | const QStringList& getRecentContest() const; 39 | QString getSelectedContest(); 40 | 41 | private: 42 | Ui::OpenContestDialog *ui; 43 | 44 | private slots: 45 | void selectionChanged(); 46 | }; 47 | 48 | #endif // OPENCONTESTDIALOG_H 49 | -------------------------------------------------------------------------------- /opencontestwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #include "opencontestwidget.h" 21 | #include "ui_opencontestwidget.h" 22 | #include "contest.h" 23 | 24 | OpenContestWidget::OpenContestWidget(QWidget *parent) : 25 | QWidget(parent), 26 | ui(new Ui::OpenContestWidget) 27 | { 28 | ui->setupUi(this); 29 | connect(ui->recentContest, SIGNAL(itemSelectionChanged()), 30 | this, SIGNAL(selectionChanged())); 31 | connect(ui->recentContest, SIGNAL(cellDoubleClicked(int, int)), 32 | this, SIGNAL(rowDoubleClicked())); 33 | connect(ui->addButton, SIGNAL(clicked()), 34 | this, SLOT(addContest())); 35 | connect(ui->deleteButton, SIGNAL(clicked()), 36 | this, SLOT(deleteContest())); 37 | connect(ui->recentContest, SIGNAL(currentCellChanged(int,int,int,int)), 38 | this, SLOT(currentRowChanged())); 39 | } 40 | 41 | OpenContestWidget::~OpenContestWidget() 42 | { 43 | delete ui; 44 | } 45 | 46 | void OpenContestWidget::setRecentContest(const QStringList &list) 47 | { 48 | recentContest = list; 49 | refreshContestList(); 50 | } 51 | 52 | void OpenContestWidget::refreshContestList() 53 | { 54 | ui->recentContest->setRowCount(0); 55 | for (int i = 0; i < recentContest.size(); ) { 56 | QFile file(recentContest[i]); 57 | if (! file.open(QFile::ReadOnly)) { 58 | recentContest.removeAt(i); 59 | continue; 60 | } 61 | QDataStream _in(&file); 62 | unsigned checkNumber; 63 | _in >> checkNumber; 64 | if (checkNumber != unsigned(MagicNumber)) { 65 | recentContest.removeAt(i); 66 | continue; 67 | } 68 | quint16 checksum; 69 | int len; 70 | _in >> checksum >> len; 71 | char *raw = new char[len]; 72 | _in.readRawData(raw, len); 73 | if (qChecksum(raw, len) != checksum) { 74 | delete[] raw; 75 | recentContest.removeAt(i); 76 | continue; 77 | } 78 | QByteArray data(raw, len); 79 | delete[] raw; 80 | data = qUncompress(data); 81 | QDataStream in(data); 82 | QString title; 83 | in >> title; 84 | ui->recentContest->setRowCount(i + 1); 85 | ui->recentContest->setItem(i, 0, new QTableWidgetItem(title)); 86 | ui->recentContest->setItem(i, 1, new QTableWidgetItem(recentContest[i])); 87 | ui->recentContest->item(i, 0)->setTextAlignment(Qt::AlignCenter); 88 | i ++; 89 | } 90 | QHeaderView *header = ui->recentContest->horizontalHeader(); 91 | header->setSectionResizeMode(QHeaderView::ResizeToContents); 92 | } 93 | 94 | void OpenContestWidget::addContest() 95 | { 96 | QString fileName = QFileDialog::getOpenFileName(this, tr("Add Contest"), QDir::homePath(), 97 | tr("Lemon contest data file (*.cdf)")); 98 | if (fileName.isEmpty()) return; 99 | fileName = fileName.replace('/', QDir::separator()); 100 | QFile file(fileName); 101 | if (! file.open(QFile::ReadOnly)) { 102 | QMessageBox::warning(this, tr("Error"), tr("Cannot open selected file"), QMessageBox::Close); 103 | return; 104 | } 105 | QDataStream in(&file); 106 | unsigned checkNumber; 107 | in >> checkNumber; 108 | if (checkNumber != unsigned(MagicNumber)) { 109 | QMessageBox::warning(this, tr("Error"), tr("Broken contest data file"), QMessageBox::Close); 110 | return; 111 | } 112 | quint16 checksum; 113 | int len; 114 | in >> checksum >> len; 115 | char *raw = new char[len]; 116 | in.readRawData(raw, len); 117 | if (qChecksum(raw, len) != checksum) { 118 | QMessageBox::warning(this, tr("Error"), tr("Broken contest data file"), QMessageBox::Close); 119 | delete[] raw; 120 | return; 121 | } 122 | delete[] raw; 123 | recentContest.prepend(fileName); 124 | refreshContestList(); 125 | } 126 | 127 | void OpenContestWidget::deleteContest() 128 | { 129 | int index = ui->recentContest->currentRow(); 130 | recentContest.removeAt(index); 131 | refreshContestList(); 132 | } 133 | 134 | void OpenContestWidget::currentRowChanged() 135 | { 136 | int index = ui->recentContest->currentRow(); 137 | if (index != -1) { 138 | ui->deleteButton->setEnabled(true); 139 | } else { 140 | ui->deleteButton->setEnabled(false); 141 | } 142 | } 143 | 144 | const QStringList& OpenContestWidget::getRecentContest() const 145 | { 146 | return recentContest; 147 | } 148 | 149 | int OpenContestWidget::getCurrentRow() const 150 | { 151 | return ui->recentContest->currentRow(); 152 | } 153 | -------------------------------------------------------------------------------- /opencontestwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef OPENCONTESTWIDGET_H 21 | #define OPENCONTESTWIDGET_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace Ui { 31 | class OpenContestWidget; 32 | } 33 | 34 | class OpenContestWidget : public QWidget 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit OpenContestWidget(QWidget *parent = 0); 40 | ~OpenContestWidget(); 41 | void setRecentContest(const QStringList&); 42 | const QStringList& getRecentContest() const; 43 | int getCurrentRow() const; 44 | 45 | private: 46 | Ui::OpenContestWidget *ui; 47 | QStringList recentContest; 48 | void refreshContestList(); 49 | 50 | private slots: 51 | void addContest(); 52 | void deleteContest(); 53 | void currentRowChanged(); 54 | 55 | signals: 56 | void selectionChanged(); 57 | void rowDoubleClicked(); 58 | }; 59 | 60 | #endif // OPENCONTESTWIDGET_H 61 | -------------------------------------------------------------------------------- /optionsdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #include "optionsdialog.h" 21 | #include "ui_optionsdialog.h" 22 | #include "settings.h" 23 | 24 | OptionsDialog::OptionsDialog(QWidget *parent) : 25 | QDialog(parent), 26 | ui(new Ui::OptionsDialog) 27 | { 28 | ui->setupUi(this); 29 | editSettings = new Settings(this); 30 | connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, 31 | this, &OptionsDialog::okayButtonClicked); 32 | } 33 | 34 | OptionsDialog::~OptionsDialog() 35 | { 36 | delete ui; 37 | } 38 | 39 | Settings* OptionsDialog::getEditSettings() 40 | { 41 | return editSettings; 42 | } 43 | 44 | void OptionsDialog::resetEditSettings(Settings *settings) 45 | { 46 | editSettings->copyFrom(settings); 47 | ui->generalSettings->resetEditSettings(editSettings); 48 | ui->compilerSettings->resetEditSettings(editSettings); 49 | ui->tabWidget->setCurrentIndex(0); 50 | } 51 | 52 | void OptionsDialog::okayButtonClicked() 53 | { 54 | ui->tabWidget->setCurrentIndex(0); 55 | if (! ui->generalSettings->checkValid()) return; 56 | ui->tabWidget->setCurrentIndex(1); 57 | if (! ui->compilerSettings->checkValid()) return; 58 | accept(); 59 | } 60 | -------------------------------------------------------------------------------- /optionsdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef OPTIONSDIALOG_H 21 | #define OPTIONSDIALOG_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | namespace Ui { 28 | class OptionsDialog; 29 | } 30 | 31 | class Settings; 32 | 33 | class OptionsDialog : public QDialog 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit OptionsDialog(QWidget *parent = 0); 39 | ~OptionsDialog(); 40 | void resetEditSettings(Settings*); 41 | Settings* getEditSettings(); 42 | 43 | private: 44 | Ui::OptionsDialog *ui; 45 | Settings *editSettings; 46 | 47 | private slots: 48 | void okayButtonClicked(); 49 | }; 50 | 51 | #endif // OPTIONSDIALOG_H 52 | -------------------------------------------------------------------------------- /qt_zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/qt_zh_CN.qm -------------------------------------------------------------------------------- /qtlockedfile/qtlockedfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCKEDFILE_H 41 | #define QTLOCKEDFILE_H 42 | 43 | #include 44 | #ifdef Q_OS_WIN 45 | #include 46 | #endif 47 | 48 | #if defined(Q_WS_WIN) 49 | # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) 50 | # define QT_QTLOCKEDFILE_EXPORT 51 | # elif defined(QT_QTLOCKEDFILE_IMPORT) 52 | # if defined(QT_QTLOCKEDFILE_EXPORT) 53 | # undef QT_QTLOCKEDFILE_EXPORT 54 | # endif 55 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) 56 | # elif defined(QT_QTLOCKEDFILE_EXPORT) 57 | # undef QT_QTLOCKEDFILE_EXPORT 58 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) 59 | # endif 60 | #else 61 | # define QT_QTLOCKEDFILE_EXPORT 62 | #endif 63 | 64 | namespace QtLP_Private { 65 | 66 | class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile 67 | { 68 | public: 69 | enum LockMode { NoLock = 0, ReadLock, WriteLock }; 70 | 71 | QtLockedFile(); 72 | QtLockedFile(const QString &name); 73 | ~QtLockedFile(); 74 | 75 | bool open(OpenMode mode); 76 | 77 | bool lock(LockMode mode, bool block = true); 78 | bool unlock(); 79 | bool isLocked() const; 80 | LockMode lockMode() const; 81 | 82 | private: 83 | #ifdef Q_OS_WIN 84 | Qt::HANDLE wmutex; 85 | Qt::HANDLE rmutex; 86 | QVector rmutexes; 87 | QString mutexname; 88 | 89 | Qt::HANDLE getMutexHandle(int idx, bool doCreate); 90 | bool waitMutex(Qt::HANDLE mutex, bool doBlock); 91 | 92 | #endif 93 | LockMode m_lock_mode; 94 | }; 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /qtlockedfile/qtlockedfile_unix.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "qtlockedfile.h" 46 | 47 | bool QtLockedFile::lock(LockMode mode, bool block) 48 | { 49 | if (!isOpen()) { 50 | qWarning("QtLockedFile::lock(): file is not opened"); 51 | return false; 52 | } 53 | 54 | if (mode == NoLock) 55 | return unlock(); 56 | 57 | if (mode == m_lock_mode) 58 | return true; 59 | 60 | if (m_lock_mode != NoLock) 61 | unlock(); 62 | 63 | struct flock fl; 64 | fl.l_whence = SEEK_SET; 65 | fl.l_start = 0; 66 | fl.l_len = 0; 67 | fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; 68 | int cmd = block ? F_SETLKW : F_SETLK; 69 | int ret = fcntl(handle(), cmd, &fl); 70 | 71 | if (ret == -1) { 72 | if (errno != EINTR && errno != EAGAIN) 73 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 74 | return false; 75 | } 76 | 77 | 78 | m_lock_mode = mode; 79 | return true; 80 | } 81 | 82 | 83 | bool QtLockedFile::unlock() 84 | { 85 | if (!isOpen()) { 86 | qWarning("QtLockedFile::unlock(): file is not opened"); 87 | return false; 88 | } 89 | 90 | if (!isLocked()) 91 | return true; 92 | 93 | struct flock fl; 94 | fl.l_whence = SEEK_SET; 95 | fl.l_start = 0; 96 | fl.l_len = 0; 97 | fl.l_type = F_UNLCK; 98 | int ret = fcntl(handle(), F_SETLKW, &fl); 99 | 100 | if (ret == -1) { 101 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 102 | return false; 103 | } 104 | 105 | m_lock_mode = NoLock; 106 | return true; 107 | } 108 | 109 | QtLockedFile::~QtLockedFile() 110 | { 111 | if (isOpen()) 112 | unlock(); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /qtsingleapplication/qtlocalpeer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCALPEER_H 41 | #define QTLOCALPEER_H 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #include "qtlockedfile/qtlockedfile.h" 48 | 49 | #if defined(Q_OS_UNIX) 50 | #include 51 | #endif 52 | 53 | class QtLocalPeer : public QObject 54 | { 55 | Q_OBJECT 56 | 57 | public: 58 | QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); 59 | bool isClient(); 60 | bool sendMessage(const QString &message, int timeout); 61 | QString applicationId() const 62 | { return id; } 63 | 64 | Q_SIGNALS: 65 | void messageReceived(const QString &message); 66 | 67 | protected Q_SLOTS: 68 | void receiveConnection(); 69 | 70 | protected: 71 | QString id; 72 | QString socketName; 73 | QLocalServer* server; 74 | QtLP_Private::QtLockedFile lockFile; 75 | 76 | private: 77 | static const char* ack; 78 | }; 79 | 80 | #endif // QTLOCALPEER_H 81 | -------------------------------------------------------------------------------- /qtsingleapplication/qtsingleapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLEAPPLICATION_H 41 | #define QTSINGLEAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | #if defined(Q_WS_WIN) 48 | # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) 49 | # define QT_QTSINGLEAPPLICATION_EXPORT 50 | # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) 51 | # if defined(QT_QTSINGLEAPPLICATION_EXPORT) 52 | # undef QT_QTSINGLEAPPLICATION_EXPORT 53 | # endif 54 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) 55 | # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) 56 | # undef QT_QTSINGLEAPPLICATION_EXPORT 57 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) 58 | # endif 59 | #else 60 | # define QT_QTSINGLEAPPLICATION_EXPORT 61 | #endif 62 | 63 | class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication 64 | { 65 | Q_OBJECT 66 | 67 | public: 68 | QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 69 | QtSingleApplication(const QString &id, int &argc, char **argv); 70 | //QtSingleApplication(int &argc, char **argv, Type type); 71 | #if defined(Q_WS_X11) 72 | QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 73 | QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 74 | QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 75 | #endif 76 | 77 | bool isRunning(); 78 | QString id() const; 79 | 80 | void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 81 | QWidget* activationWindow() const; 82 | 83 | // Obsolete: 84 | void initialize(bool dummy = true) 85 | { isRunning(); Q_UNUSED(dummy) } 86 | 87 | public Q_SLOTS: 88 | bool sendMessage(const QString &message, int timeout = 5000); 89 | void activateWindow(); 90 | 91 | 92 | Q_SIGNALS: 93 | void messageReceived(const QString &message); 94 | 95 | 96 | private: 97 | void sysInit(const QString &appId = QString()); 98 | QtLocalPeer *peer; 99 | QWidget *actWin; 100 | }; 101 | 102 | #endif // QTSINGLEAPPLICATION_H 103 | -------------------------------------------------------------------------------- /qtsingleapplication/qtsinglecoreapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLECOREAPPLICATION_H 41 | #define QTSINGLECOREAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | class QtSingleCoreApplication : public QCoreApplication 48 | { 49 | Q_OBJECT 50 | 51 | public: 52 | QtSingleCoreApplication(int &argc, char **argv); 53 | QtSingleCoreApplication(const QString &id, int &argc, char **argv); 54 | 55 | bool isRunning(); 56 | QString id() const; 57 | 58 | public Q_SLOTS: 59 | bool sendMessage(const QString &message, int timeout = 5000); 60 | 61 | 62 | Q_SIGNALS: 63 | void messageReceived(const QString &message); 64 | 65 | 66 | private: 67 | QtLocalPeer* peer; 68 | }; 69 | 70 | #endif // QTSINGLECOREAPPLICATION_H 71 | -------------------------------------------------------------------------------- /resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | rod.png 4 | downarrow.png 5 | uparrow.png 6 | add.png 7 | cross.png 8 | icon.png 9 | 10 | 11 | Lemon_zh_CN.qm 12 | qt_zh_CN.qm 13 | 14 | 15 | -------------------------------------------------------------------------------- /resultviewer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef RESULTVIEWER_H 21 | #define RESULTVIEWER_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class Contest; 35 | 36 | class ResultViewer : public QTableWidget 37 | { 38 | Q_OBJECT 39 | public: 40 | explicit ResultViewer(QWidget *parent = 0); 41 | void changeEvent(QEvent*); 42 | void contextMenuEvent(QContextMenuEvent*); 43 | void setContest(Contest*); 44 | 45 | public slots: 46 | void refreshViewer(); 47 | void judgeSelected(); 48 | void judgeAll(); 49 | 50 | private: 51 | Contest *curContest; 52 | QAction *deleteContestantAction; 53 | QAction *detailInformationAction; 54 | QAction *judgeSelectedAction; 55 | QAction *deleteContestantKeyAction; 56 | void clearPath(const QString&); 57 | 58 | private slots: 59 | void deleteContestant(); 60 | void detailInformation(); 61 | 62 | signals: 63 | void contestantDeleted(); 64 | }; 65 | 66 | #endif // RESULTVIEWER_H 67 | -------------------------------------------------------------------------------- /rod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/rod.png -------------------------------------------------------------------------------- /selftestutil.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef SELFTESTUTIL_H 21 | #define SELFTESTUTIL_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class Contest; 30 | 31 | class SelfTestUtil : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit SelfTestUtil(QObject *parent = 0); 36 | static void clearPath(const QString&); 37 | static void makeSelfTest(QWidget*, Contest*); 38 | 39 | signals: 40 | 41 | public slots: 42 | 43 | }; 44 | 45 | #endif // SELFTESTUTIL_H 46 | -------------------------------------------------------------------------------- /settings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef SETTINGS_H 20 | #define SETTINGS_H 21 | 22 | #include 23 | #include 24 | 25 | class Compiler; 26 | 27 | class Settings : public QObject 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit Settings(QObject *parent = 0); 32 | 33 | int getDefaultFullScore() const; 34 | int getDefaultTimeLimit() const; 35 | int getDefaultMemoryLimit() const; 36 | int getCompileTimeLimit() const; 37 | int getSpecialJudgeTimeLimit() const; 38 | int getFileSizeLimit() const; 39 | int getNumberOfThreads() const; 40 | const QString& getDefaultInputFileExtension() const; 41 | const QString& getDefaultOutputFileExtension() const; 42 | const QStringList& getInputFileExtensions() const; 43 | const QStringList& getOutputFileExtensions() const; 44 | const QStringList& getRecentContest() const; 45 | const QList& getCompilerList() const; 46 | const QString& getUiLanguage() const; 47 | const QString& getDiffPath() const; 48 | 49 | void setDefaultFullScore(int); 50 | void setDefaultTimeLimit(int); 51 | void setDefaultMemoryLimit(int); 52 | void setCompileTimeLimit(int); 53 | void setSpecialJudgeTimeLimit(int); 54 | void setFileSizeLimit(int); 55 | void setNumberOfThreads(int); 56 | void setDefaultInputFileExtension(const QString&); 57 | void setDefaultOutputFileExtension(const QString&); 58 | void setInputFileExtensions(const QString&); 59 | void setOutputFileExtensions(const QString&); 60 | void setRecentContest(const QStringList&); 61 | void setUiLanguage(const QString&); 62 | 63 | void addCompiler(Compiler*); 64 | void deleteCompiler(int); 65 | Compiler* getCompiler(int); 66 | void swapCompiler(int, int); 67 | void copyFrom(Settings*); 68 | void saveSettings(); 69 | void loadSettings(); 70 | 71 | static int upperBoundForFullScore(); 72 | static int upperBoundForTimeLimit(); 73 | static int upperBoundForMemoryLimit(); 74 | static int upperBoundForFileSizeLimit(); 75 | static int upperBoundForNumberOfThreads(); 76 | static QString dataPath(); 77 | static QString sourcePath(); 78 | static QString temporaryPath(); 79 | static QString selfTestPath(); 80 | 81 | private: 82 | QList compilerList; 83 | int defaultFullScore; 84 | int defaultTimeLimit; 85 | int defaultMemoryLimit; 86 | int compileTimeLimit; 87 | int specialJudgeTimeLimit; 88 | int fileSizeLimit; 89 | int numberOfThreads; 90 | QString defaultInputFileExtension; 91 | QString defaultOutputFileExtension; 92 | QStringList inputFileExtensions; 93 | QStringList outputFileExtensions; 94 | QStringList recentContest; 95 | QString uiLanguage; 96 | QString diffPath; 97 | }; 98 | 99 | #endif // SETTINGS_H 100 | -------------------------------------------------------------------------------- /summarytree.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef SUMMARYTREE_H 21 | #define SUMMARYTREE_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class Settings; 32 | class Contest; 33 | 34 | class SummaryTree : public QTreeWidget 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit SummaryTree(QWidget *parent = 0); 39 | void changeEvent(QEvent*); 40 | void setContest(Contest*); 41 | void setSettings(Settings*); 42 | void contextMenuEvent(QContextMenuEvent*); 43 | 44 | private: 45 | int addCount; 46 | Contest *curContest; 47 | Settings *settings; 48 | QAction *addTaskAction; 49 | QAction *addTestCaseAction; 50 | QAction *addTestCasesAction; 51 | QAction *addTaskKeyAction; 52 | QAction *addTestCaseKeyAction; 53 | QAction *deleteTaskAction; 54 | QAction *deleteTestCaseAction; 55 | QAction *deleteTaskKeyAction; 56 | QAction *deleteTestCaseKeyAction; 57 | 58 | private slots: 59 | void addTask(); 60 | void addTestCase(); 61 | void addTestCases(); 62 | void deleteTask(); 63 | void deleteTestCase(); 64 | void selectionChanged(); 65 | void itemChanged(QTreeWidgetItem*); 66 | void titleChanged(const QString&); 67 | }; 68 | 69 | #endif // SUMMARYTREE_H 70 | -------------------------------------------------------------------------------- /task.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TASK_H 20 | #define TASK_H 21 | 22 | #include 23 | #include 24 | 25 | class TestCase; 26 | class Settings; 27 | 28 | class Task : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | enum TaskType { Traditional, AnswersOnly }; 33 | enum ComparisonMode { LineByLineMode, IgnoreSpacesMode, ExternalToolMode, RealNumberMode, SpecialJudgeMode }; 34 | 35 | explicit Task(QObject *parent = 0); 36 | 37 | const QList& getTestCaseList() const; 38 | const QString& getProblemTile() const; 39 | const QString& getSourceFileName() const; 40 | const QString& getInputFileName() const; 41 | const QString& getOutputFileName() const; 42 | bool getStandardInputCheck() const; 43 | bool getStandardOutputCheck() const; 44 | TaskType getTaskType() const; 45 | ComparisonMode getComparisonMode() const; 46 | const QString& getDiffArguments() const; 47 | int getRealPrecision() const; 48 | const QString& getSpecialJudge() const; 49 | QString getCompilerConfiguration(const QString&) const; 50 | const QString& getAnswerFileExtension() const; 51 | 52 | void setProblemTitle(const QString&); 53 | void setSourceFileName(const QString&); 54 | void setInputFileName(const QString&); 55 | void setOutputFileName(const QString&); 56 | void setStandardInputCheck(bool); 57 | void setStandardOutputCheck(bool); 58 | void setTaskType(TaskType); 59 | void setComparisonMode(ComparisonMode); 60 | void setDiffArguments(const QString&); 61 | void setRealPrecision(int); 62 | void setSpecialJudge(const QString&); 63 | void setCompilerConfiguration(const QString&, const QString&); 64 | void setAnswerFileExtension(const QString&); 65 | 66 | void addTestCase(TestCase*); 67 | TestCase* getTestCase(int) const; 68 | void deleteTestCase(int); 69 | void refreshCompilerConfiguration(Settings*); 70 | int getTotalTimeLimit() const; 71 | void writeToStream(QDataStream&); 72 | void readFromStream(QDataStream&); 73 | 74 | private: 75 | QList testCaseList; 76 | QString problemTitle; 77 | QString sourceFileName; 78 | QString inputFileName; 79 | QString outputFileName; 80 | bool standardInputCheck; 81 | bool standardOutputCheck; 82 | TaskType taskType; 83 | ComparisonMode comparisonMode; 84 | QString diffArguments; 85 | int realPrecision; 86 | QString specialJudge; 87 | QMap compilerConfiguration; 88 | QString answerFileExtension; 89 | 90 | signals: 91 | void problemTitleChanged(const QString&); 92 | void compilerConfigurationRefreshed(); 93 | }; 94 | 95 | #endif // TASK_H 96 | -------------------------------------------------------------------------------- /taskeditwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TASKEDITWIDGET_H 20 | #define TASKEDITWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class TaskEditWidget; 28 | } 29 | 30 | class Settings; 31 | class Task; 32 | 33 | class TaskEditWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit TaskEditWidget(QWidget *parent = 0); 39 | ~TaskEditWidget(); 40 | void changeEvent(QEvent*); 41 | void setEditTask(Task*); 42 | void setSettings(Settings*); 43 | 44 | private: 45 | Ui::TaskEditWidget *ui; 46 | Settings *settings; 47 | Task *editTask; 48 | void refreshWidgetState(); 49 | 50 | private slots: 51 | void problemTitleChanged(const QString&); 52 | void setToTraditional(bool); 53 | void setToAnswersOnly(bool); 54 | void sourceFileNameChanged(const QString&); 55 | void inputFileNameChanged(const QString&); 56 | void outputFileNameChanged(const QString&); 57 | void standardInputCheckChanged(); 58 | void standardOutputCheckChanged(); 59 | void comparisonModeChanged(); 60 | void diffArgumentsChanged(const QString&); 61 | void realPrecisionChanged(int); 62 | void specialJudgeChanged(const QString&); 63 | void refreshProblemTitle(const QString&); 64 | void refreshCompilerConfiguration(); 65 | void compilerSelectionChanged(); 66 | void configurationSelectionChanged(); 67 | void answerFileExtensionChanged(const QString&); 68 | 69 | signals: 70 | void dataPathChanged(); 71 | }; 72 | 73 | #endif // TASKEDITWIDGET_H 74 | -------------------------------------------------------------------------------- /testcase.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "testcase.h" 20 | #include "settings.h" 21 | 22 | TestCase::TestCase(QObject *parent) : 23 | QObject(parent) 24 | { 25 | } 26 | 27 | int TestCase::getFullScore() const 28 | { 29 | return fullScore; 30 | } 31 | 32 | int TestCase::getTimeLimit() const 33 | { 34 | return timeLimit; 35 | } 36 | 37 | int TestCase::getMemoryLimit() const 38 | { 39 | return memoryLimit; 40 | } 41 | 42 | const QStringList& TestCase::getInputFiles() const 43 | { 44 | return inputFiles; 45 | } 46 | 47 | const QStringList& TestCase::getOutputFiles() const 48 | { 49 | return outputFiles; 50 | } 51 | 52 | void TestCase::setFullScore(int score) 53 | { 54 | fullScore = score; 55 | } 56 | 57 | void TestCase::setTimeLimit(int limit) 58 | { 59 | timeLimit = limit; 60 | } 61 | 62 | void TestCase::setMemoryLimit(int limit) 63 | { 64 | memoryLimit = limit; 65 | } 66 | 67 | void TestCase::setInputFiles(int index, const QString &fileName) 68 | { 69 | if (0 <= index && index < inputFiles.size()) { 70 | inputFiles[index] = fileName; 71 | } 72 | } 73 | 74 | void TestCase::setOutputFiles(int index, const QString &fileName) 75 | { 76 | if (0 <= index && index < outputFiles.size()) { 77 | outputFiles[index] = fileName; 78 | } 79 | } 80 | 81 | void TestCase::addSingleCase(const QString &inputFile, const QString &outputFile) 82 | { 83 | inputFiles.append(inputFile); 84 | outputFiles.append(outputFile); 85 | } 86 | 87 | void TestCase::deleteSingleCase(int index) 88 | { 89 | inputFiles.removeAt(index); 90 | outputFiles.removeAt(index); 91 | } 92 | 93 | void TestCase::writeToStream(QDataStream &out) 94 | { 95 | out << fullScore; 96 | out << timeLimit; 97 | out << memoryLimit; 98 | QStringList _inputFiles(inputFiles); 99 | for (int i = 0; i < _inputFiles.size(); i ++) { 100 | _inputFiles[i].replace(QDir::separator(), '/'); 101 | } 102 | QStringList _outputFiles(outputFiles); 103 | for (int i = 0; i < _outputFiles.size(); i ++) { 104 | _outputFiles[i].replace(QDir::separator(), '/'); 105 | } 106 | out << _inputFiles; 107 | out << _outputFiles; 108 | } 109 | 110 | void TestCase::readFromStream(QDataStream &in) 111 | { 112 | in >> fullScore; 113 | in >> timeLimit; 114 | in >> memoryLimit; 115 | in >> inputFiles; 116 | in >> outputFiles; 117 | for (int i = 0; i < inputFiles.size(); i ++) { 118 | inputFiles[i].replace('/', QDir::separator()); 119 | } 120 | for (int i = 0; i < outputFiles.size(); i ++) { 121 | outputFiles[i].replace('/', QDir::separator()); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /testcase.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TESTCASE_H 20 | #define TESTCASE_H 21 | 22 | #include 23 | #include 24 | 25 | class TestCase : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | explicit TestCase(QObject *parent = 0); 30 | int getFullScore() const; 31 | int getTimeLimit() const; 32 | int getMemoryLimit() const; 33 | const QStringList& getInputFiles() const; 34 | const QStringList& getOutputFiles() const; 35 | void setFullScore(int); 36 | void setTimeLimit(int); 37 | void setMemoryLimit(int); 38 | void setInputFiles(int, const QString&); 39 | void setOutputFiles(int, const QString&); 40 | void addSingleCase(const QString&, const QString&); 41 | void deleteSingleCase(int); 42 | void writeToStream(QDataStream&); 43 | void readFromStream(QDataStream&); 44 | 45 | private: 46 | QStringList inputFiles; 47 | QStringList outputFiles; 48 | int fullScore; 49 | int timeLimit; 50 | int memoryLimit; 51 | }; 52 | 53 | #endif // TESTCASE_H 54 | -------------------------------------------------------------------------------- /testcaseeditwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #ifndef TESTCASEEDITWIDGET_H 21 | #define TESTCASEEDITWIDGET_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Ui { 30 | class TestCaseEditWidget; 31 | } 32 | 33 | class Settings; 34 | class TestCase; 35 | 36 | class TestCaseEditWidget : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit TestCaseEditWidget(QWidget *parent = 0); 42 | ~TestCaseEditWidget(); 43 | void changeEvent(QEvent*); 44 | void setEditTestCase(TestCase*, bool); 45 | void setSettings(Settings*); 46 | 47 | private: 48 | Ui::TestCaseEditWidget *ui; 49 | TestCase *editTestCase; 50 | Settings *settings; 51 | QAction *deleteAction; 52 | void refreshFileList(); 53 | 54 | private slots: 55 | void addSingleCase(); 56 | void deleteSingleCase(); 57 | void fullScoreChanged(const QString&); 58 | void timeLimitChanged(const QString&); 59 | void memoryLimitChanged(const QString&); 60 | void fileListSelectionChanged(); 61 | void fileListItemChanged(QTableWidgetItem*); 62 | 63 | signals: 64 | void dataPathChanged(); 65 | }; 66 | 67 | #endif // TESTCASEEDITWIDGET_H 68 | -------------------------------------------------------------------------------- /uparrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WAAutoMaton/Lemon/a59773f59cdbbe9b46bd0f47ad4493e347812a79/uparrow.png -------------------------------------------------------------------------------- /watcher/watcher_unix.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | Copyright (C) 2016 Menci 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ***************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int pid; 31 | 32 | void cleanUp() { 33 | kill(pid, SIGKILL); 34 | exit(0); 35 | } 36 | 37 | /* 38 | * On Linux the member ru_maxrss of struct rusage is "the maximum resident set size used (in *kilobytes*)". 39 | * On OS X it's "the maximum resident set size utilized (in *bytes*)". 40 | * 41 | * convertMemoryUsage() will return the value in bytes. ** 42 | */ 43 | 44 | int convertMemoryUsage(int maxrss) { 45 | #ifdef __APPLE__ 46 | return maxrss; 47 | #else 48 | return maxrss * 1024; 49 | #endif 50 | } 51 | 52 | int main(int argc, char *argv[]) { 53 | int timeLimit, memoryLimit; 54 | sscanf(argv[5], "%d", &timeLimit); 55 | timeLimit = (timeLimit - 1) / 1000 + 1; 56 | sscanf(argv[6], "%d", &memoryLimit); 57 | memoryLimit *= 1024 * 1024; 58 | 59 | pid = fork(); 60 | if (pid > 0) { 61 | signal(SIGINT, cleanUp); 62 | signal(SIGABRT, cleanUp); 63 | signal(SIGTERM, cleanUp); 64 | struct rusage usage; 65 | int status; 66 | if (wait4(pid, &status, 0, &usage) == -1) 67 | return 1; 68 | if (WIFEXITED(status)) { 69 | if (WEXITSTATUS(status) == 1) return 1; 70 | printf("%d\n", (int)(usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000)); 71 | printf("%d\n", convertMemoryUsage((int)(usage.ru_maxrss))); 72 | if (WEXITSTATUS(status) != 0) return 2; 73 | return 0; 74 | } 75 | if (WIFSIGNALED(status)) { 76 | printf("%d\n", (int)(usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000)); 77 | printf("%d\n", convertMemoryUsage((int)(usage.ru_maxrss))); 78 | if (WTERMSIG(status) == SIGXCPU) return 3; 79 | if (WTERMSIG(status) == SIGKILL) return 4; 80 | if (WTERMSIG(status) == SIGABRT) return 4; 81 | return 2; 82 | } 83 | } else { 84 | if (strlen(argv[2]) > 0) freopen(argv[2], "r", stdin); 85 | if (strlen(argv[3]) > 0) freopen(argv[3], "w", stdout); 86 | if (strlen(argv[4]) > 0) freopen(argv[4], "w", stderr); 87 | if (memoryLimit != -1) 88 | setrlimit(RLIMIT_AS, &(struct rlimit){memoryLimit, memoryLimit}); 89 | setrlimit(RLIMIT_CPU, &(struct rlimit){timeLimit, timeLimit + 1}); 90 | setrlimit(RLIMIT_STACK,&(struct rlimit){RLIM_INFINITY,RLIM_INFINITY}); 91 | if (execlp("bash", "bash", "-c", argv[1], NULL) == -1) return 1; 92 | } 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /watcher/watcher_unix.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += console 3 | CONFIG -= app_bundle 4 | CONFIG -= qt 5 | 6 | SOURCES += \ 7 | watcher_unix.c 8 | 9 | TARGET = watcher_unix 10 | -------------------------------------------------------------------------------- /welcomedialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "welcomedialog.h" 20 | #include "ui_welcomedialog.h" 21 | 22 | WelcomeDialog::WelcomeDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::WelcomeDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->openContestWidget, SIGNAL(selectionChanged()), 29 | this, SLOT(selectionChanged())); 30 | connect(ui->newContestWidget, SIGNAL(informationChanged()), 31 | this, SLOT(informationChanged())); 32 | connect(ui->tabWidget, SIGNAL(currentChanged(int)), 33 | this, SLOT(tabIndexChanged(int))); 34 | connect(ui->openContestWidget, SIGNAL(rowDoubleClicked()), 35 | this, SLOT(accept())); 36 | } 37 | 38 | WelcomeDialog::~WelcomeDialog() 39 | { 40 | delete ui; 41 | } 42 | 43 | void WelcomeDialog::setRecentContest(const QStringList &list) 44 | { 45 | ui->openContestWidget->setRecentContest(list); 46 | } 47 | 48 | QString WelcomeDialog::getContestTitle() 49 | { 50 | return ui->newContestWidget->getContestTitle(); 51 | } 52 | 53 | QString WelcomeDialog::getSavingName() 54 | { 55 | return ui->newContestWidget->getSavingName(); 56 | } 57 | 58 | QString WelcomeDialog::getContestPath() 59 | { 60 | return ui->newContestWidget->getContestPath(); 61 | } 62 | 63 | const QStringList& WelcomeDialog::getRecentContest() const 64 | { 65 | return ui->openContestWidget->getRecentContest(); 66 | } 67 | 68 | QString WelcomeDialog::getSelectedContest() 69 | { 70 | return ui->openContestWidget->getRecentContest().at(ui->openContestWidget->getCurrentRow()); 71 | } 72 | 73 | int WelcomeDialog::getCurrentTab() const 74 | { 75 | return ui->tabWidget->currentIndex(); 76 | } 77 | 78 | void WelcomeDialog::selectionChanged() 79 | { 80 | if (ui->openContestWidget->getCurrentRow() != -1) { 81 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 82 | } else { 83 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 84 | } 85 | } 86 | 87 | void WelcomeDialog::informationChanged() 88 | { 89 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 90 | } 91 | 92 | void WelcomeDialog::tabIndexChanged(int index) 93 | { 94 | if (index == 0) { 95 | if (ui->openContestWidget->getCurrentRow() != -1) { 96 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 97 | } else { 98 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 99 | } 100 | } else { 101 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /welcomedialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef WELCOMEDIALOG_H 20 | #define WELCOMEDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class WelcomeDialog; 28 | } 29 | 30 | class WelcomeDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit WelcomeDialog(QWidget *parent = 0); 36 | ~WelcomeDialog(); 37 | void setRecentContest(const QStringList&); 38 | QString getContestTitle(); 39 | QString getSavingName(); 40 | QString getContestPath(); 41 | const QStringList& getRecentContest() const; 42 | QString getSelectedContest(); 43 | int getCurrentTab() const; 44 | 45 | private: 46 | Ui::WelcomeDialog *ui; 47 | 48 | private slots: 49 | void selectionChanged(); 50 | void informationChanged(); 51 | void tabIndexChanged(int); 52 | }; 53 | 54 | #endif // WELCOMEDIALOG_H 55 | --------------------------------------------------------------------------------