statswinimpl::statswinimpl(Hero *h) : QWidget(0,0) { setupUi(this); hero = h; hwin = new herowinimpl(hero); diary = new diarywinimpl(); stayontopToggle(false); connect(hero, SIGNAL(done(QString)), this, SLOT(loginDone(QString))); //трей #ifdef Q_WS_WIN QResource res = QResource("bin/icon.bmp"); #else QResource res = QResource("src/icon_128.png"); #endif QPixmap pix; pix.loadFromData(res.data(), res.size()); QIcon ico = QIcon(pix); tray = new QSystemTrayIcon(ico); tray->setVisible(true); connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); //меню QMenu *menu = new QMenu(); QAction *hideshow = menu->addAction(tr("Скрыть/Показать")); connect(hideshow, SIGNAL(triggered()), this, SLOT(hideshow())); menu->addSeparator(); showmess = menu->addAction(tr("Показывать сообщения")); showmess->setCheckable(true); showmess->setChecked(true); QAction *stayontop = menu->addAction(tr("Поверх всех окон")); stayontop->setCheckable(true); stayontop->setChecked(false); connect(stayontop, SIGNAL(toggled(bool)), this, SLOT(stayontopToggle(bool))); menu->addSeparator(); QAction *herotrbt = menu->addAction(tr("Герой")); connect(herotrbt, SIGNAL(triggered()), this, SLOT(on_btInfo_pressed())); QAction *diarytrbt = menu->addAction(tr("Дневник")); connect(diarytrbt, SIGNAL(triggered()), this, SLOT(on_btDiary_pressed())); menu->addSeparator(); settingsDialog = new Dialog(this); connect(settingsDialog,SIGNAL(accepted()),this,SLOT(updateSettings())); QAction *settingstrbt = menu->addAction(tr("Настройки")); connect(settingstrbt,SIGNAL(triggered()),this,SLOT(settings())); menu->addSeparator(); //settingstrbt->setEnabled(false); QAction *exit = menu->addAction(tr("Выход")); connect(exit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(exit, SIGNAL(triggered()), tray, SLOT(hide())); tray->setContextMenu(menu); //таймер timer = new QTimer(this); timer->start(15000); connect(timer, SIGNAL(timeout()), this, SLOT(update())); mess = new HeroMessager(); QSettings settings("godville.net", "godvilleQT"); restoreGeometry(settings.value("statWinGeometry").toByteArray()); this->setWindowOpacity(settings.value("statWinOp",100).toInt()/100); }
void InitializationThread::initTranslations(void) { //Search for language files const QDir qmDirectory(":/localization"); const QStringList qmFiles = qmDirectory.entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name); //Make sure we found at least one translation if(qmFiles.count() < 1) { qFatal("Could not find any translation files!"); return; } //Initialize variables const QString langResTemplate(":/localization/%1.txt"); QRegExp langIdExp("^LameXP_(\\w\\w)\\.qm$", Qt::CaseInsensitive); //Add all available translations for(QStringList::ConstIterator iter = qmFiles.constBegin(); iter != qmFiles.constEnd(); iter++) { const QString langFile = qmDirectory.absoluteFilePath(*iter); QString langId, langName; unsigned int systemId = 0, country = 0; if(QFileInfo(langFile).isFile() && (langIdExp.indexIn(*iter) >= 0)) { langId = langIdExp.cap(1).toLower(); QResource langRes = QResource(langResTemplate.arg(*iter)); if(langRes.isValid() && langRes.size() > 0) { QByteArray data = QByteArray::fromRawData(reinterpret_cast<const char*>(langRes.data()), langRes.size()); QTextStream stream(&data, QIODevice::ReadOnly); stream.setAutoDetectUnicode(false); stream.setCodec("UTF-8"); while(!(stream.atEnd() || (stream.status() != QTextStream::Ok))) { QStringList langInfo = stream.readLine().simplified().split(",", QString::SkipEmptyParts); if(langInfo.count() >= 3) { systemId = langInfo.at(0).trimmed().toUInt(); country = langInfo.at(1).trimmed().toUInt(); langName = langInfo.at(2).trimmed(); break; } } } } if(!(langId.isEmpty() || langName.isEmpty() || (systemId == 0))) { if(MUtils::Translation::insert(langId, langFile, langName, systemId, country)) { qDebug("Registering translation: %s = %s (%u) [%u]", MUTILS_UTF8(*iter), MUTILS_UTF8(langName), systemId, country); } else { qWarning("Failed to register: %s", langFile.toLatin1().constData()); } } } qDebug("All registered.\n"); }