int _tmain(int argc, _TCHAR* argv[]) { _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); //_CrtSetBreakAlloc(2030); int retVal = appInit(); appQuit(); return retVal; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow w; w.show(); QObject::connect(&w, SIGNAL(appQuit()), &app, SLOT(quit())); QApplication::setStyle(new QPlastiqueStyle); return app.exec(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { for (int i = 0; i < 6 ;i++) { levels.append(0); } ui->setupUi(this); settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "enkidu", "battalbot"); ui->le_server->setText(settings->value("server", "").toString()); ui->le_channel->setText(settings->value("channel", "").toString()); ui->le_botname->setText(settings->value("botname", "").toString()); QHash<QString, QVariant> tmp; auths = settings->value("auths", tmp).toHash(); onFinish = false; added = 0; QLocale::setDefault(QLocale::English); trayIcon = new QSystemTrayIcon(); QMenu *menu = new QMenu(); QAction *actionQuit = new QAction("Quit", trayIcon); menu->addAction(actionQuit); trayIcon->setContextMenu(menu); trayIcon->setIcon(QIcon(":/icon.png")); trayIcon->show(); this->setWindowIcon(QIcon(":/icon.png")); this->setWindowTitle("eRepublik wall-watching BOT"); connect(ui->pb_connect, SIGNAL(clicked()), this, SLOT(connectToServer())); irc = new Irc(this); reader = new Reader; battle = new Battle; refreshTree(); connect(battle, SIGNAL(getWall()), reader, SLOT(read())); connect(ui->pb_StartCount, SIGNAL(clicked()), this, SLOT(getInfo())); connect(reader, SIGNAL(startCounting(int,QTime)), battle, SLOT(startCounting(int, QTime))); connect(reader, SIGNAL(startCounting(int,QTime)), this, SLOT(setInitialWall(int,QTime))); connect(battle, SIGNAL(setTimeT(QTime)), this, SLOT(setTimeElapsed(QTime))); connect(reader, SIGNAL(wall(int,bool)), battle, SLOT(actWall(int,bool))); connect(reader, SIGNAL(wall(int,bool)), this, SLOT(setWall(int,bool))); connect(battle, SIGNAL(setText(QString)), irc, SLOT(write(QString))); connect(reader, SIGNAL(battleInfo(QString)), irc, SLOT(setTopic(QString))); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(irc, SIGNAL(authRequest(QString,QString,QString)), this, SLOT(auth(QString,QString,QString))); connect(irc, SIGNAL(wallRequest(QString,QString)), this, SLOT(wall(QString,QString))); connect(irc, SIGNAL(playerRequest(QString)), reader, SLOT(getPlayer(QString))); connect(reader, SIGNAL(playerInfo(QString)), irc, SLOT(write(QString))); connect(ui->pb_authAdd, SIGNAL(clicked()), this, SLOT(addAuth())); connect(ui->pb_delAuth, SIGNAL(clicked()), this, SLOT(delAuth())); connect(actionQuit, SIGNAL(triggered()), this, SLOT(appQuit())); curve = new QwtPlotCurve(); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->attach(ui->qwtPlot); for (int i = 0; i < 6; i++) { QwtPlotCurve *line = new QwtPlotCurve(); if (i == 0 || i == 5) { line->setPen(QPen(QColor(0,0,255))); } else { line->setPen(QPen(QColor(0,200,0))); } line->attach(ui->qwtPlot); lines.append(line); } }
void Application::parseArguments(QStringList args) { QFileInfo program(args.at(0)); QString programName("renderer"); if (program.exists()) programName = program.baseName(); if (args.contains("-h") || args.contains("-help") || args.contains("--help")) { std::cout << "Usage: " << programName.toLatin1().data() << " [-version]" << " [-gui]" << " [-bookjs path]" << " [-custom-css path]" << " [-output path]" << " URL" << std::endl; appQuit(0); } if (args.contains("-version")) { std::cout << applicationName().toLatin1().data() << " " << applicationVersion().toLatin1().data() #if defined(Q_PROCESSOR_X86_32) << " x86" #elif defined(Q_PROCESSOR_X86_64) << " amd64" #endif << std::endl; appQuit(0); } m_gui = args.contains("-gui"); int bookjsPathIndex = args.indexOf("-bookjs"); if (bookjsPathIndex != -1) { QString path = takeOptionValue(&args, bookjsPathIndex); QDir dir(path); if (! dir.exists()) { appQuit(1, QString("path does not point to a directory: %1").arg(path)); } m_rendererOptions.bookjsPath = dir.absolutePath(); } int cssPathIndex = args.indexOf("-custom-css"); if (cssPathIndex != -1) { QString path = takeOptionValue(&args, cssPathIndex); if (! QFileInfo(path).isReadable()) { appQuit(1, QString("file does not exist or is not readable: %1").arg(path)); } QFile file(path); if (! file.open(QFile::ReadOnly)) { appQuit(1, QString("cout not open file: %1").arg(path)); } m_rendererOptions.customCSS = QTextStream(&file).readAll(); } int outputPathIndex = args.indexOf("-output"); if (outputPathIndex != -1) m_rendererOptions.outputFilePath = takeOptionValue(&args, outputPathIndex); int lastArg = args.lastIndexOf(QRegExp("^-.*")); m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); }