void VimeoUserWindow::onUserStatusChanged(QVimeo::ResourcesRequest::Status status) {
    switch (status) {
    case QVimeo::ResourcesRequest::Loading:
        showProgressIndicator();
        return;
    case QVimeo::ResourcesRequest::Ready:
        loadUserUi();
        break;
    case QVimeo::ResourcesRequest::Failed:
        QMessageBox::critical(this, tr("Error"), m_user->errorString());
        break;
    default:
        break;
    }
    
    hideProgressIndicator();
    disconnect(m_user, SIGNAL(statusChanged(QVimeo::ResourcesRequest::Status)),
               this, SLOT(onUserStatusChanged(QVimeo::ResourcesRequest::Status)));
    connect(m_user, SIGNAL(statusChanged(QVimeo::ResourcesRequest::Status)),
            this, SLOT(onUserUpdateStatusChanged(QVimeo::ResourcesRequest::Status)));
    connect(m_user, SIGNAL(subscribedChanged()), this, SLOT(onUserSubscribedChanged())); 
    
    if ((!m_user->isSubscribed()) && (!Vimeo::instance()->userId().isEmpty())) {
        m_user->checkIfSubscribed();
    }
}
VimeoUserWindow::VimeoUserWindow(const QString &id, StackedWindow *parent) :
    StackedWindow(parent),
    m_user(new VimeoUser(this)),
    m_model(new QStringListModel(QStringList() << tr("Videos") << tr("Likes") << tr("Albums")
                                               << tr("Subscriptions"), this)),
    m_avatar(new Image(this)),
    m_view(new ListView(this)),
    m_scrollArea(new QScrollArea(this)),
    m_titleLabel(new QLabel(this)),
    m_statsLabel(new QLabel(this)),
    m_descriptionLabel(new TextBrowser(this)),
    m_subscribeButton(new QPushButton(tr("Subscribe"), this))
{
    loadBaseUi();
    connect(m_user, SIGNAL(statusChanged(QVimeo::ResourcesRequest::Status)),
            this, SLOT(onUserStatusChanged(QVimeo::ResourcesRequest::Status)));
            
    m_user->loadUser(id);
}
int MoodBox::MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: onUserAccountUpdated(); break;
        case 1: onUserStatusChanged((*reinterpret_cast< UserStatus::UserStatusEnum(*)>(_a[1]))); break;
        case 2: onServerError((*reinterpret_cast< ServerResponseHandler::ServerError(*)>(_a[1]))); break;
        case 3: onShowExceptionDialogSendingMessage((*reinterpret_cast< ContactResultCode::ContactResultCodeEnum(*)>(_a[1])),(*reinterpret_cast< qint32(*)>(_a[2]))); break;
        case 4: onLogonStarted(); break;
        case 5: onLogonStopped(); break;
        case 6: onLogonSuccess(); break;
        case 7: showWindow(); break;
        case 8: shutDown(); break;
        case 9: onLogoutCompleted(); break;
        case 10: relogon(); break;
        case 11: offline((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 12: offline(); break;
        case 13: { bool _r = logout((*reinterpret_cast< bool(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 14: { bool _r = logout();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 15: showSettings(); break;
        case 16: ipcMessage((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 17: addFriendByLogin(); break;
        case 18: forceQuit(); break;
        case 19: onTrayIconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        case 20: on_contactListButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 21: on_drawButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 22: on_historyButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 23: onDownloadNewVersion(); break;
        case 24: onInviteCodeAccepted(); break;
        case 25: onRegistrationSuccess(); break;
        case 26: onResetPassword(); break;
        case 27: onShowClipart(); break;
        case 28: onReply((*reinterpret_cast< const QImage(*)>(_a[1]))); break;
        case 29: showTvWidget(); break;
        case 30: showLogonWidget((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 31: showLogonWidget(); break;
        case 32: showInviteCodeWidget(); break;
        case 33: showRegistrationWidget(); break;
        case 34: showForgotPasswordWidget(); break;
        case 35: showInfoWidget(); break;
        case 36: showWaitingWidget(); break;
        case 37: stopWaitingWidget(); break;
        case 38: hideWaitingWidget(); break;
        case 39: cancelWaitingWidget(); break;
        case 40: onRegistrationBack(); break;
        case 41: onInviteCodeNeeded(); break;
        case 42: onContactSelected((*reinterpret_cast< qint32(*)>(_a[1]))); break;
        case 43: onContactImageDrop((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const QImage(*)>(_a[2]))); break;
        case 44: onSoundStateChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 45: onPrivateMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break;
        case 46: onChannelMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break;
        case 47: onFriendsMessageReceived((*reinterpret_cast< const MessageKey(*)>(_a[1]))); break;
        case 48: onMessageSent(); break;
        case 49: showHelp(); break;
        case 50: requestFinished((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 51: dataProcessedProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
        case 52: cancelHttpRequest(); break;
        default: ;
        }
        _id -= 53;
    }
    return _id;
}
Esempio n. 4
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
}