Example #1
0
int main(int argc,char *argv[])
{
	QApplication::setStyle("Fusion");
	QApplication a(argc,argv);
	QDir::setCurrent(a.applicationDirPath());
	QString locale=QLocale::system().name();
	QTranslator myTrans;
	myTrans.load(locale+".qm","./translations");
	QTranslator qtTrans;
	qtTrans.load(locale+".qt.qm","./translations");
	a.installTranslator(&myTrans);
	a.installTranslator(&qtTrans);
	Utils::loadConfig();
	Shield::init();
	Cookie::init();
	setDefaultFont();
	setToolTipBase();
	a.connect(&a,&QApplication::aboutToQuit,[](){
		Cookie::free();
		Shield::free();
		Utils::saveConfig();
	});
	Interface w;
	w.show();
	return a.exec();
}
Example #2
0
int main(int argc,char *argv[])
{
	QDir::setCurrent(QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath());
	Local::addLibraryPath("./plugins");
	Local::setStyle("Fusion");
	Local a(argc,argv);
	Config::load();
	int single;
	if((single=Config::getValue("/Interface/Single",1))){
		QLocalSocket socket;
		socket.connectToServer("BiliLocalInstance");
		if(socket.waitForConnected()){
			QDataStream s(&socket);
			s<<a.arguments().mid(1);
			socket.waitForBytesWritten();
			return 0;
		}
	}
	Shield::load();
	loadTranslator();
	setDefaultFont();
	setToolTipBase();
	a.connect(&a,&Local::aboutToQuit,[](){
		Shield::save();
		Config::save();
	});
	qsrand(QTime::currentTime().msec());
	Interface w;
	Plugin::loadPlugins();
	w.show();
	w.tryLocal(a.arguments().mid(1));
	QLocalServer *server=NULL;
	if(single){
		server=new QLocalServer(qApp);
		server->listen("BiliLocalInstance");
		QObject::connect(server,&QLocalServer::newConnection,[&](){
			QLocalSocket *r=server->nextPendingConnection();
			r->waitForReadyRead();
			QDataStream s(r);
			QStringList args;
			s>>args;
			r->deleteLater();
			w.tryLocal(args);
		});
	}
Example #3
0
int main(int argc, char *argv[])
{
	Local a(argc, argv);
	int single;
	if ((single = Config::getValue("/Interface/Single", 1))){
		QLocalSocket socket;
		socket.connectToServer("BiliLocalInstance");
		if (socket.waitForConnected()){
			QDataStream s(&socket);
			s << a.arguments().mid(1);
			socket.waitForBytesWritten();
			return 0;
		}
	}
	loadTranslator();
	setDefaultFont();
	setToolTipBase();
	Interface w;
	Plugin::loadPlugins();
	if (!w.testAttribute(Qt::WA_WState_ExplicitShowHide)){
		w.show();
	}
	w.tryLocal(a.arguments().mid(1));
	QLocalServer *server = nullptr;
	if (single){
		server = new QLocalServer(lApp);
		server->listen("BiliLocalInstance");
		QObject::connect(server, &QLocalServer::newConnection, [&](){
			QLocalSocket *r = server->nextPendingConnection();
			r->waitForReadyRead();
			QDataStream s(r);
			QStringList args;
			s >> args;
			delete r;
			w.tryLocal(args);
		});
	}