예제 #1
0
void TimeGuard::setupUi()
{
  setupIcons();
  ui->setupUi(this);
  logOffAdmin();
  ui->userNameLabel->setText(user->getName());
  ui->logBrowser->setPlainText(fileManager->readLog(user->getName()));
  ui->timerLCD->displayDefaultTime();

  this->setWindowIcon(programIcon);
  setupTray();
  adminLoginDialog = new AdminLoginDialog(this, messages, admin);
}
예제 #2
0
MainWindow::MainWindow(QtSingleApplication &app)
	: QMainWindow(NULL, MAINWINDOWFLAGS), 
	  isLoggingOn(false), isShuttingDown(false), 
	  showWelcomeScreen(false), isInviteCodeNeed(false), isMousePressed(false), showClipartWindow(false),
	  widgetIndexBeforeWaiting(-1),
	  contactList(NULL), drawingWindow(NULL), historyWindow(NULL), 
	  trayIcon(0), trayMenu(NULL), trayClickTimer(-1), trayConnectingTimer(-1), 	
	  autoUpdater(this), http(NULL), reply(NULL)
{
   // AEInstallEventHandler(
    
	setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);

	TimeMeasure t("MainWindow");

	progressDialog = NULL;

	setupUi(this);

	t.showTimePassedAfterSetupUi();

	// connect signals from second copy of the application
	connect(&app, SIGNAL(messageReceived(const QString & )), this, SLOT(showWindow()));

	isPlaySounds = ProgramSettings::getPlaySouns();

	// Connect infomanager & server
	connect(INFOMANAGER, SIGNAL(userAccountUpdated()), this, SLOT(onUserAccountUpdated()));
	connect(INFOMANAGER, SIGNAL(userStatusChanged(UserStatus::UserStatusEnum)), this, SLOT(onUserStatusChanged(UserStatus::UserStatusEnum)));

	connect(SERVER, SIGNAL(serverError(ServerResponseHandler::ServerError)), this, SLOT(onServerError(ServerResponseHandler::ServerError)));
	connect(SERVER, SIGNAL(logoutCompleted()), this, SLOT(onLogoutCompleted()));

	// Connect message manager
	connect(MESSAGEMANAGER, SIGNAL(privateMessageReceived(qint32, const MessageKey &)), this, SLOT(onPrivateMessageReceived(qint32, const MessageKey &)));
	connect(MESSAGEMANAGER, SIGNAL(friendsMessageReceived(const MessageKey &)), this, SLOT(onFriendsMessageReceived(const MessageKey &)));
	connect(MESSAGEMANAGER, SIGNAL(channelMessageReceived(qint32, const MessageKey &)), this, SLOT(onChannelMessageReceived(qint32, const MessageKey &)));
	connect(MESSAGEMANAGER, SIGNAL(showExceptionDialogSendingMessage(ContactResultCode::ContactResultCodeEnum, qint32)), this, SLOT(onShowExceptionDialogSendingMessage(ContactResultCode::ContactResultCodeEnum, qint32)));
		
	// Connect logon
	connect(logonWidget, SIGNAL(registerNewUser()), this, SLOT(showRegistrationWidget()));
	connect(logonWidget, SIGNAL(inviteCodeNeeded()), this, SLOT(onInviteCodeNeeded()));
	connect(logonWidget, SIGNAL(forgotPassword()), this, SLOT(showForgotPasswordWidget()));
	connect(logonWidget, SIGNAL(logonStarted()), this, SLOT(onLogonStarted()));
	connect(logonWidget, SIGNAL(logonStopped()), this, SLOT(onLogonStopped()));
	connect(logonWidget, SIGNAL(successLogon()), this, SLOT(onLogonSuccess()));
	connect(logonWidget, SIGNAL(showSettings()), this, SLOT(showSettings()));

	// connect widgets with waiting widget
	connect(waitingWidget, SIGNAL(cancel()), this, SLOT(cancelWaitingWidget()));
	connect(logonWidget, SIGNAL(waitingStart()), this, SLOT(showWaitingWidget()));
	connect(logonWidget, SIGNAL(waitingStop()), this, SLOT(stopWaitingWidget()));
	connect(registrationWidget, SIGNAL(waitingStart()), this, SLOT(showWaitingWidget()));
	connect(registrationWidget, SIGNAL(waitingHide()), this, SLOT(cancelWaitingWidget()));
	connect(forgotPasswordWidget, SIGNAL(waitingStart()), this, SLOT(showWaitingWidget()));
	connect(forgotPasswordWidget, SIGNAL(waitingStop()), this, SLOT(cancelWaitingWidget()));
	connect(inviteCodeWidget, SIGNAL(waitingStart()), this, SLOT(showWaitingWidget()));
	connect(inviteCodeWidget, SIGNAL(waitingStop()), this, SLOT(cancelWaitingWidget()));

	// Connect invite
	connect(inviteCodeWidget, SIGNAL(next()), this, SLOT(onInviteCodeAccepted()));
	connect(inviteCodeWidget, SIGNAL(back()), this, SLOT(showLogonWidget()));

	// Connect registration
	connect(registrationWidget, SIGNAL(back()), this, SLOT(onRegistrationBack()));
	connect(registrationWidget, SIGNAL(registrationSuccess()), this, SLOT(onRegistrationSuccess()));

	// Connect info
	connect(infoWidget, SIGNAL(finished()), this, SLOT(showLogonWidget()));

	// Connect forgot password
	connect(forgotPasswordWidget, SIGNAL(finished()), this, SLOT(onResetPassword()));
	connect(forgotPasswordWidget, SIGNAL(back()), this, SLOT(showLogonWidget()));

	// Connect welcome
	connect(welcomeWidget, SIGNAL(finished()), this, SLOT(showTvWidget()));

	// Connect buttons
	connect(tvCloseButton, SIGNAL(clicked()), this, SLOT(close()));

	// Connect TVWidget
	connect(previousButton, SIGNAL(clicked()), tvWidget, SLOT(previousMessage()));
	connect(tvWidget, SIGNAL(previousMessageAvailable(bool)), previousButton, SLOT(setEnabled(bool)));
	connect(tvWidget, SIGNAL(previousMessageAvailable(bool)), this, SLOT(showTvWidget()));
	
	connect(nextButton, SIGNAL(clicked()), tvWidget, SLOT(nextMessage()));
	connect(tvWidget, SIGNAL(nextMessageAvailable(bool)), nextButton, SLOT(setEnabled(bool)));
	connect(tvWidget, SIGNAL(nextMessageAvailable(bool)), this, SLOT(showTvWidget()));

	connect(tvWidget, SIGNAL(replyRequest(const QImage &)), this, SLOT(onReply(const QImage &)));

	tvWidget->setChatLabel(tr(ALL_FRIENDS_CHAT_LABEL));

	// Init variables & windows
	autoUpdater.startCheckingPaused();
	connect(&autoUpdater, SIGNAL(downloadNewVersion()), this, SLOT(onDownloadNewVersion()));

	clipartWindow = new ClipartWindow(this);

	createChildWindows();

	loadSettings();

	// start logon
	showLogonWidget(true);
	logonWidget->start(true);

	buttonsFrame->hide();

	setupTray();
	updateWindowTitle();

	// show help by pressing F1
	QShortcut * showHelpShortCut = new QShortcut(this);
	showHelpShortCut->setKey(Qt::Key_F1);
	connect(showHelpShortCut, SIGNAL(activated()), this, SLOT(showHelp()));
    
#ifdef Q_WS_MAC
    macInit();
#endif
}
예제 #3
0
파일: mainwindow.cpp 프로젝트: Thaodan/ROAL
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    torrent = NULL;

    // Center the widget
    this->setGeometry(QStyle::alignedRect(
                          Qt::LeftToRight,
                          Qt::AlignCenter,
                          this->size(),
                          qApp->desktop()->availableGeometry()
                          ));

    // Create the tray icon
    setupTray();

    // Translator
    translator = new QTranslator();

    // Set the current launcher version
    settings.setSetting("launcherVersion", QCoreApplication::applicationVersion());

    // Get path and split it to remove /launcher
    QString tmpPath = QApplication::applicationDirPath().replace('\\','/');

    QStringList realPathList = tmpPath.split("/");
    tmpPath = "";

#ifdef Q_OS_LINUX
    for(int i = 0; i < realPathList.size() - 2; i++)
    {
        tmpPath += realPathList.at(i) + "/";
    }

    if(!tmpPath.endsWith("/"))
    {
        tmpPath += "/";
    }
#else
    for(int i = 0; i < realPathList.size() - 1; i++)
    {
        tmpPath += realPathList.at(i) + "/";
    }

    if(!tmpPath.endsWith("/"))
    {
        tmpPath += "/";
    }
#endif

    settings.setSetting("installLocation", tmpPath);

    //Create all dirs, maybe one is missing
    QStringList dirs;
    dirs << tmpPath + "game"
         << tmpPath + "game/bin"
         << tmpPath + "game/data"
         << tmpPath + "game/lib"
         << tmpPath + "game/data/logs"
         << tmpPath + "game/data/relics_of_annorath"
         << tmpPath + "game/data/relics_of_annorath/configuration"
         << tmpPath + "game/data/relics_of_annorath/configuration/gui"
         << tmpPath + "game/data/relics_of_annorath/terrains"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones/1_14_westzones"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones/Layers"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1/3_14_nordzone1"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1/Terrain_Masken"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/4_14_Nordzone2"
         << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/4_14_Nordzone2/4_14_nordzone2";

    for(int i = 0; i < dirs.size(); i++)
    {
        QDir dir(dirs.at(i));
        if(!dir.exists())
            QDir().mkpath(dirs.at(i));
    }

    // Remove window borders
    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground, true);

    // Set window state as not moving
    moving = false;
    setMouseTracking(false);

    //@FIXME: What does this?
    //this->ui->webView->setDisabled(true);

    // Set not muted and torrent not paused
    muted = false;
    pause = false;

    // Torrent is not done yet
    torrentDone = 0;

    // Hide the game start button
    //this->ui->buttonPlay->hide();
    this->ui->buttonPlay->setText(tr("Wait..."));
    this->ui->buttonPlay->setEnabled(0);

    // Style progressbar
    this->ui->progressBar->setStyleSheet("QProgressBar {"
                                         "  color: rgb(0, 0, 0);"
                                         "  border: 0px solid;"
                                         "  background-color: rgba(255, 255, 127, 40);"
                                         "}"
                                         "QProgressBar::chunk {"
                                         "  color: rgb(0, 0, 0);"
                                         "background-color: rgba(42, 85, 0, 90);"
                                         "  width: 20px;"
                                         "}");

    // Add values to the boxes for language seleciton
    ui->boxLanguage->addItem( "English", "english" );
    ui->boxLanguage->addItem( "Español", "spanish" );
    ui->boxLanguage->addItem( "Deutsch", "german" );
    ui->boxLanguage->addItem( "Français", "french" );
    ui->boxLanguage->addItem( "Italiano", "italian" );
    ui->boxLanguage->addItem( "Polski", "polish" );
    ui->boxLanguage->addItem( "Português", "portuguese" );
    ui->boxLanguage->addItem( "Svenska", "swedish" );
    ui->boxLanguage->addItem( "ελληνικά", "greek" );

    // Add rendering options
    ui->boxRendering->addItem("OpenGL", "opengl");

#ifdef Q_OS_WIN
    // Set rendering options
    ui->boxRendering->addItem("DirectX 9", "direct3d9");
    ui->boxRendering->addItem("DirectX 11", "direct3d11");
#endif

    // Get configured values for the language
    ui->boxLanguage->setCurrentIndex(ui->boxLanguage->findData(settings.getSetting(QString("language"))));

    // Get renderer
    ui->boxRendering->setCurrentIndex(ui->boxRendering->findData(settings.getSetting(QString("rendering"))));

    // Connect event
    connect(ui->boxLanguage, SIGNAL(currentIndexChanged(int)),SLOT(slot_boxLanguage_currentIndexChanged(int)));
    connect(ui->boxRendering, SIGNAL(currentIndexChanged(int)),SLOT(slot_boxRendering_currentIndexChanged(int)));

    // Get torrent values
    ui->lineTCP->setText(settings.getSetting(QString("torPort")));
    ui->lineMaxDL->setText(settings.getSetting(QString("torDLMax")));
    ui->lineMaxUL->setText(settings.getSetting(QString("torULMax")));

    // Set http status
    if(settings.getSetting("useHTTP") == "true")
    {
        ui->checkHTTP->setChecked(true);
    }
    else
    {
        ui->checkHTTP->setChecked(false);
    }

    ui->webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    ui->webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff );

    // Set link handling
    ui->webView_2->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(ui->webView_2, SIGNAL(linkClicked( QUrl )), this, SLOT( linkClickedSlot( QUrl ) ));

    // Check configuration
    refreshConfiguration();

    // Retranslate to the new language
    retranslate();

    // Create about page
    about = new AboutLauncher();

    // Start
    configurePath();
}