Пример #1
0
SideBar::SideBar(QWidget *parent)
    :QFrame(parent), m_lastButton( 0 )
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );

    m_buttonGroup = new QButtonGroup( this );
    m_buttonGroup->setExclusive( true );

    layout->addWidget( ui.nowPlaying = newButton( tr( "Now Playing" ), m_buttonGroup, this ), Qt::AlignHCenter );
    ui.nowPlaying->setObjectName( "nowPlaying" );
    layout->addWidget( ui.scrobbles = newButton( tr( "Scrobbles" ), m_buttonGroup, this ), Qt::AlignHCenter);
    ui.scrobbles->setObjectName( "scrobbles" ); 
    layout->addWidget( ui.profile = newButton( tr( "Profile" ), m_buttonGroup, this ), Qt::AlignHCenter);
    ui.profile->setObjectName( "profile" );
    layout->addWidget( ui.friends = newButton( tr( "Friends" ), m_buttonGroup, this ), Qt::AlignHCenter);
    ui.friends->setObjectName( "friends" );
    layout->addWidget( ui.radio = newButton( tr( "Radio" ), m_buttonGroup, this ), Qt::AlignHCenter);
    ui.radio->setObjectName( "radio" );
    layout->addStretch( 1 );

    connect( m_buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), SLOT(onButtonClicked(QAbstractButton*)));

    ui.nowPlaying->click();

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) );

    onSessionChanged( aApp->currentSession() );
}
void QBluetoothTransferReplyBluez::sessionStarted(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QDBusObjectPath, QVariantMap> reply = *watcher;
    if (reply.isError()) {
        qCWarning(QT_BT_BLUEZ) << "Failed to start obex session:"
                               << reply.error().name() << reply.reply().errorMessage();

        m_errorStr = QBluetoothTransferReply::tr("Push session cannot be started");
        m_error = QBluetoothTransferReply::SessionError;
        m_finished = true;
        m_running = false;

        cleanupSession();

        emit QBluetoothTransferReply::error(m_error);
        emit finished(this);

        watcher->deleteLater();
        return;
    }

    const QDBusObjectPath path = reply.argumentAt<0>();
    const QVariantMap map = reply.argumentAt<1>();
    m_transfer_path = path.path();

    //watch the transfer
    OrgFreedesktopDBusPropertiesInterface *properties = new OrgFreedesktopDBusPropertiesInterface(
                            QStringLiteral("org.bluez.obex"), path.path(),
                            QDBusConnection::sessionBus(), this);
    connect(properties, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
            SLOT(sessionChanged(QString,QVariantMap,QStringList)));

    watcher->deleteLater();
}
Пример #3
0
RadioWidget::RadioWidget(QWidget *parent)
    :QFrame( parent ), ui( new Ui::RadioWidget )
{
    ui->setupUi( this );

    ui->lastStationLabel->setObjectName( "title" );
    ui->personalLabel->setObjectName( "title" );
    ui->networkLabel->setObjectName( "title" );
    ui->recentLabel->setObjectName( "title" );

    ui->splitter->setObjectName( "splitter" );
    ui->splitter_2->setObjectName( "splitter" );
    ui->splitter_3->setObjectName( "splitter" );
    ui->splitter_4->setObjectName( "splitter" );

    connect( ui->subscribe, SIGNAL(clicked()), SLOT(onSubscribeClicked()) );
    connect( ui->listen, SIGNAL(clicked()), SLOT(onListenClicked()) );

    // need to know when we are playing the radio so we can switch between now playing and last playing
    connect( &RadioService::instance(), SIGNAL(tuningIn(RadioStation)), SLOT(onTuningIn(RadioStation) ) );
    connect( &RadioService::instance(), SIGNAL(stopped()), SLOT(onRadioStopped()));
    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(Track,Track)), SLOT(onTrackStarted(Track,Track)) );

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session) ) );

    m_movie = new QMovie( ":/loading_meta.gif", "GIF", this );
    m_movie->setCacheMode( QMovie::CacheAll );
    ui->spinner->setMovie( m_movie );

    refresh( aApp->currentSession() );
}
ScrobblesListWidget::ScrobblesListWidget( QWidget* parent )
    :QListWidget( parent ), m_trackItem( 0 )
{
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef Q_OS_MAC
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) );
#endif

    setAttribute( Qt::WA_MacNoClickThrough );
    setAttribute( Qt::WA_MacShowFocusRect, false );

    setUniformItemSizes( false );
    setSortingEnabled( false );
    setSelectionMode( QAbstractItemView::NoSelection );
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

    connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)));

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );
    connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track)));
    connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused()));
    connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed()));
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()));

    onSessionChanged( aApp->currentSession() );
}
Пример #5
0
/**
 * @brief Handle client disconnect from a session
 *
 * The session takes care of the client itself. Here, we clean up after the session
 * in case it needs to be closed.
 * @param session
 */
void SessionServer::userDisconnectedEvent(SessionState *session)
{
	bool delSession = false;
	if(session->userCount()==0) {
		logger::debug() << session << "Last user left";

		bool hasSnapshot = session->mainstream().hasSnapshot();

		// A non-persistent session is deleted when the last user leaves
		// A persistent session can also be deleted if it doesn't contain a snapshot point.
		if(!hasSnapshot || !session->isPersistent()) {
			if(hasSnapshot)
				logger::info() << session << "Closing non-persistent session";
			else
				logger::info() << session << "Closing persistent session due to lack of snapshot point!";

			delSession = true;
		}

		// If the hibernatable flag is set, it means we want to put the session
		// into storage as soon as possible
		delSession |= session->isHibernatable();
	}

	if(delSession)
		destroySession(session);
	else
		emit sessionChanged(SessionDescription(*session));

	emit userDisconnected();
}
Пример #6
0
/*----------------------------------------------------------------------------*/
MeasureWindow::MeasureWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MeasureWindow)
{
  m_created = false;
  ui->setupUi(this);
  ui->profileCombo->addItems(config->profileList());
  ui->profileCombo->setCurrentIndex(config->profileIndex());
  m_created = true;
  m_newMeasure = true;
  onProfileChanged(config->profileIndex());

  connect(database, SIGNAL(dbError(QString)), this, SLOT(onDatabaseError()));

  connect(controller, SIGNAL(cmdSendError()), this, SLOT(onCmdSendError()));
  connect(controller, SIGNAL(cmdSendOk()), this, SLOT(onCmdSendOk()));
  connect(controller, SIGNAL(currentStretch(double)), this, SLOT(onCurrentStretch(double)));
  connect(controller, SIGNAL(endOfMeasuring()), this, SLOT(onEndOfMeasuring()));
  connect(controller, SIGNAL(measure(double,double,int)), this, SLOT(onMeasure(double,double,int)));
  connect(controller, SIGNAL(nextCasseteRequest()), this, SLOT(onNextCasseteRequest()));
  connect(controller, SIGNAL(noParticle()), this, SLOT(onNoParticle()));
  connect(controller, SIGNAL(serialReceived(QString)), this, SLOT(onSerialReceived(QString)));
  connect(controller, SIGNAL(statusChanged(int)), this, SLOT(onStatusChanged(int)));
  connect(controller, SIGNAL(sizeReceived(double)), this, SLOT(onSizeReceived(double)));

  connect(session, SIGNAL(sessionChanged()), this, SLOT(onSessionChanged()));
  connect(session, SIGNAL(measureListChanged()), this, SLOT(onMeasureListChanged()));

  ui->sessionBox->setSession(session);

  measureModel = new MeasureModel(this);
  ui->measureTable->setModel(measureModel);
  //connect(session, SIGNAL(measureListChanged()), measureModel, SLOT(update()));

  histogrammPlotter = new HistogrammPlotter();
  //  ui->currentHPlotWidget->setPlotter(histogrammPlotter);
  curvePlotter = new CurvePlotter();
  curvePlotter->x.setShowValues(false);
  curvePlotter->x.setText(tr("[s]"));
  curvePlotter->x.setDecimals(0);
  curvePlotter->x.setSteps(3);
  curvePlotter->x.setMax(3000);


  curvePlotter->y.setShowValues(true);
  curvePlotter->y.setText(tr("[N]"));
  curvePlotter->y.setDecimals(1);

  curvePlotter->setFiled(false);
  curvePlotter->setPointSize(4);

  curvePlotter->setStyle(AxisPlotter::StrokeStyle);


  ui->currentValuePlotWidget->setPlotter(curvePlotter);
  intervalCount = 6;

  controller->start();
}
Пример #7
0
UserMenu::UserMenu( QWidget* p )
    :QMenu( p )
{
    connect( qApp, SIGNAL(rosterUpdated()), SLOT(refresh()));
    connect( qApp, SIGNAL(sessionChanged(unicorn::Session) ), SLOT( onSessionChanged( unicorn::Session) ) );

    refresh();
}
Пример #8
0
void SessionServer::setSessionStore(SessionStore *store)
{
	Q_ASSERT(store);
	_store = store;
	store->setParent(this);

	connect(store, SIGNAL(sessionAvailable(SessionDescription)), this, SIGNAL(sessionChanged(SessionDescription)));
}
Пример #9
0
void SessionServer::initSession(Session *session)
{
	session->setHistoryLimit(_historyLimit);
	session->setPersistenceAllowed(allowPersistentSessions());
	session->setWelcomeMessage(welcomeMessage());

	connect(session, &Session::userConnected, this, &SessionServer::moveFromLobby);
	connect(session, &Session::userDisconnected, this, &SessionServer::userDisconnectedEvent);
	connect(session, &Session::sessionAttributeChanged, [this](Session *ses) { emit sessionChanged(SessionDescription(*ses)); });

	connect(session, &Session::requestAnnouncement, this, &SessionServer::announceSession);
	connect(session, &Session::requestUnlisting, this, &SessionServer::unlistSession);

	_sessions.append(session);

	emit sessionCreated(session);
	emit sessionChanged(SessionDescription(*session));
}
void SessionStorageServiceImpl::setActivePatient(const QString& activePatientFolder)
{
	if (activePatientFolder == mActivePatientFolder)
		return;

	mActivePatientFolder = activePatientFolder;

	emit sessionChanged();
}
void
unicorn::Application::init()
{
#ifdef Q_OS_MAC
    addLibraryPath( applicationDirPath() + "/../plugins" );
#elif defined Q_OS_WIN
    addLibraryPath( applicationDirPath() + "/plugins" );
#endif

#ifdef Q_WS_MAC
    qt_mac_set_menubar_icons( false );
#endif

    CoreApplication::init();

    setupHotKeys();

#ifdef __APPLE__
    setGetURLEventHandler();
    AEEventHandlerUPP urlHandler = NewAEEventHandlerUPP( appleEventHandler );
    AEInstallEventHandler( kInternetEventClass, kAEGetURL, urlHandler, 0, false );

    setOpenApplicationEventHandler();
    AEEventHandlerUPP openHandler = NewAEEventHandlerUPP( appleEventHandler );
    AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, openHandler, 0, false );
#endif

#ifdef Q_WS_MAC
#define CSS_PATH "/../Resources/"
#else
#define CSS_PATH "/"
#endif

    refreshStyleSheet();

    translate();

    m_icm = new lastfm::InternetConnectionMonitor( this );

    connect( m_icm, SIGNAL(up(QString)), this, SIGNAL(internetConnectionUp()));
    connect( m_icm, SIGNAL(down(QString)), this, SIGNAL(internetConnectionDown()));

    connect( m_bus, SIGNAL(wizardRunningQuery(QString)), SLOT(onWizardRunningQuery(QString)));
    connect( m_bus, SIGNAL(sessionQuery(QString)), SLOT(onBusSessionQuery(QString)));
    connect( m_bus, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onBusSessionChanged(unicorn::Session)));
    connect( m_bus, SIGNAL(lovedStateChanged(bool)), SIGNAL(busLovedStateChanged(bool)));

    m_bus->board();

#ifdef __APPLE__
    setQuitOnLastWindowClosed( false );
#endif
}
Пример #12
0
/**
 * @brief Handle the move of a client from the lobby to a session
 * @param session
 * @param client
 */
void SessionServer::moveFromLobby(Session *session, Client *client)
{
	logger::debug() << client << "moved from lobby to" << session;
	Q_ASSERT(_lobby.contains(client));
	_lobby.removeOne(client);

	// the session handles disconnect events from now on
	disconnect(client, &Client::loggedOff, this, &SessionServer::lobbyDisconnectedEvent);

	emit userLoggedIn();
	emit sessionChanged(SessionDescription(*session));
}
Пример #13
0
void QuickChatController::setChatSession(ChatSession *session)
{
	if (m_session.data() == session)
		return;

	if(m_session) {
		m_session.data()->disconnect(this);
		m_session.data()->removeEventFilter(this);
	} else
		m_session = session;
	m_session.data()->installEventFilter(this);
	loadSettings();
	emit sessionChanged(session);
}
Пример #14
0
void SessionServer::initSession(SessionState *session)
{
	session->setHistoryLimit(_historyLimit);
	session->setPersistenceAllowed(allowPersistentSessions());

	connect(session, &SessionState::userConnected, this, &SessionServer::moveFromLobby);
	connect(session, &SessionState::userDisconnected, this, &SessionServer::userDisconnectedEvent);
	connect(session, &SessionState::sessionAttributeChanged, [this](SessionState *ses) { emit sessionChanged(SessionDescription(*ses)); });

	_sessions.append(session);

	emit sessionCreated(session);
	emit sessionChanged(SessionDescription(*session));
}
NothingPlayingWidget::NothingPlayingWidget( QWidget* parent )
    :QFrame( parent ),
      ui( new Ui::NothingPlayingWidget )
{   
    ui->setupUi( this );

    setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->top->setAttribute( Qt::WA_LayoutUsesWidgetRect );

    ui->contents->setAttribute( Qt::WA_LayoutUsesWidgetRect );

    onSessionChanged( aApp->currentSession() );

    ui->scrobble->setText( tr( "<h2>Scrobble from your music player</h2>"
                               "<p>Start listening to some music in your media player. You can see more information about the tracks you play on the Now Playing tab.</p>") );

    ui->itunes->hide();
    ui->wmp->hide();
    ui->winamp->hide();
    ui->foobar->hide();

#if defined( Q_OS_WIN ) || defined( Q_OS_MAC )
    ui->itunes->setVisible( true ); // always show iTunes on Mac
    ui->itunes->setAttribute( Qt::WA_LayoutUsesWidgetRect );

    connect( ui->itunes, SIGNAL(clicked()), SLOT(oniTunesClicked()));

#ifndef Q_OS_MAC
    unicorn::PluginList pluginList;
    ui->itunes->setVisible( pluginList.pluginById( "itw" )->isAppInstalled() );
    ui->wmp->setVisible( pluginList.pluginById( "wmp" )->isAppInstalled() );
    ui->wmp->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->winamp->setVisible( pluginList.pluginById( "wa2" )->isAppInstalled() );
    ui->winamp->setAttribute( Qt::WA_LayoutUsesWidgetRect );
    ui->foobar->setVisible( pluginList.pluginById( "foo3" )->isAppInstalled() );
    ui->foobar->setAttribute( Qt::WA_LayoutUsesWidgetRect );

    connect( ui->wmp, SIGNAL(clicked()), SLOT(onWMPClicked()));
    connect( ui->winamp, SIGNAL(clicked()), SLOT(onWinampClicked()));
    connect( ui->foobar, SIGNAL(clicked()), SLOT(onFoobarClicked()));
#endif
#endif

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) );
}
Пример #16
0
ScrobbleService::ScrobbleService()
{
    qRegisterMetaType<Track>("Track");

/// mediator
    m_mediator = new PlayerMediator(this);
    connect( m_mediator, SIGNAL(activeConnectionChanged( PlayerConnection* )), SLOT(setConnection( PlayerConnection* )) );
    
/// listeners
    try{
#ifdef Q_OS_MAC
        ITunesListener* itunes = new ITunesListener(m_mediator);
        connect(itunes, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));

        SpotifyListenerMac* spotify = new SpotifyListenerMac(m_mediator);
        connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif
#ifdef Q_OS_WIN
        SpotifyListenerWin* spotify = new SpotifyListenerWin(m_mediator);
        connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif

        QObject* o = new PlayerListener(m_mediator);
        connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
        o = new LegacyPlayerListener(m_mediator);
        connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#else
        Mpris2Listener* mpris2 = new Mpris2Listener(m_mediator);
        connect(mpris2, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
        mpris2->createConnection();
#endif
    }
    catch(std::runtime_error& e){
        qWarning() << e.what();
        //TODO user visible warning
    }

    m_mediator->follow( new RadioConnection( this ) );


    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) );
    resetScrobbler();
}
Пример #17
0
ScrobbleService::ScrobbleService()
{
/// mediator
    m_mediator = new PlayerMediator(this);
    connect( m_mediator, SIGNAL(activeConnectionChanged( PlayerConnection* )), SLOT(setConnection( PlayerConnection* )) );
    
/// listeners
    try{
#ifdef Q_OS_MAC
        ITunesListener* itunes = new ITunesListener(m_mediator);
        connect(itunes, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
        itunes->start();

        SpotifyListenerMac* spotify = new SpotifyListenerMac(m_mediator);
        connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif
#ifdef Q_OS_WIN
        SpotifyListenerWin* spotify = new SpotifyListenerWin(m_mediator);
        connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif

        QObject* o = new PlayerListener(m_mediator);
        connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
        o = new LegacyPlayerListener(m_mediator);
        connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif

#ifdef QT_DBUS_LIB
        DBusListener* dbus = new DBusListener(mediator);
        connect(dbus, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*)));
#endif
    }
    catch(std::runtime_error& e){
        qWarning() << e.what();
        //TODO user visible warning
    }

    m_mediator->follow( new RadioConnection( this ) );


    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) );
    resetScrobbler();
}
Пример #18
0
/**
 * @brief Handle client disconnect from a session
 *
 * The session takes care of the client itself. Here, we clean up after the session
 * in case it needs to be closed.
 * @param session
 */
void SessionServer::userDisconnectedEvent(Session *session)
{
	bool delSession = false;
	if(session->userCount()==0) {
		logger::debug() << session << "Last user left";

		// A non-persistent session is deleted when the last user leaves
		// A persistent session can also be deleted if it doesn't contain a snapshot point.
		if(!session->isPersistent()) {
			logger::info() << session << "Closing non-persistent session";
			logger::info() << session << "History size was" << session->mainstream().lengthInBytes() << "bytes";
			delSession = true;
		}
	}

	if(delSession)
		destroySession(session);
	else
		emit sessionChanged(SessionDescription(*session));

	emit userDisconnected();
}
void SessionStorageServiceImpl::loadPatientSilent(QString choosenDir)
{
	if (this->isActivePatient(choosenDir))
		return;
	this->clearPatientSilent();
	if (choosenDir == QString::null)
		return; // On cancel

	QString filename = QDir(choosenDir).absoluteFilePath(this->getXmlFileName());
	QDomDocument doc = this->readXmlFile(filename);

	mActivePatientFolder = choosenDir; // must set path before emitting isLoading()

	if (!doc.isNull())
	{
		//Read the xml
		QDomElement element = doc.documentElement();
		emit isLoading(element);
		emit isLoadingSecond(element);
	}

	emit sessionChanged();
}
Пример #20
0
FriendListWidget::FriendListWidget(QWidget *parent) :
    QWidget(parent),
    ui( new Ui::FriendListWidget )
{
    ui->setupUi( this );

#ifdef Q_OS_MAC
    connect( ui->friends->verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) );
#endif

    ui->noFriends->setText( tr( "<h3>You haven't made any friends on Last.fm yet.</h3>"
                                "<p>Find your Facebook friends and email contacts on Last.fm quickly and easily using the friend finder.</p>" ) );

    connect( ui->findFriends, SIGNAL(clicked()), SLOT(onFindFriends()) );

#if QT_VERSION >= 0x040700
    // The placeholder property was introduced in Qt 4.7
    ui->filter->setPlaceholderText( tr( "Search for a friend by username or real name" ) );
#endif
    ui->filter->setAttribute( Qt::WA_MacShowFocusRect, false );

    ui->friends->setObjectName( "friends" );
    ui->friends->setAttribute( Qt::WA_MacShowFocusRect, false );

    connect( ui->filter, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString)));

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) );

    m_movie = new QMovie( ":/loading_meta.gif", "GIF", this );
    m_movie->setCacheMode( QMovie::CacheAll );
    ui->spinner->setMovie( m_movie );

    ui->stackedWidget->setCurrentWidget( ui->spinnerPage );
    m_movie->start();

    onSessionChanged( aApp->currentSession() );
}
Пример #21
0
KateMainWindow::KateMainWindow (KConfig *sconfig, const QString &sgroup)
    : KateMDI::MainWindow (0)
{
  setObjectName((QString("__KateMainWindow#%1").arg(uniqueID)).toLatin1());
  // first the very important id
  myID = uniqueID;
  uniqueID++;

  new KateMainWindowAdaptor( this );
  m_dbusObjectPath = "/MainWindow/" + QString::number( myID );
  QDBusConnection::sessionBus().registerObject( m_dbusObjectPath, this );

  m_modignore = false;

  // here we go, set some usable default sizes
  if (!initialGeometrySet())
  {
    int scnum = QApplication::desktop()->screenNumber(parentWidget());
    QRect desk = QApplication::desktop()->screenGeometry(scnum);

    QSize size;

    // try to load size
    if (sconfig)
    {
      KConfigGroup cg( sconfig, sgroup );
      size.setWidth (cg.readEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ));
      size.setHeight (cg.readEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ));
    }

    // if thats fails, try to reuse size
    if (size.isEmpty())
    {
      // first try to reuse size known from current or last created main window ;=)
      if (KateApp::self()->mainWindows () > 0)
      {
        KateMainWindow *win = KateApp::self()->activeMainWindow ();

        if (!win)
          win = KateApp::self()->mainWindow (KateApp::self()->mainWindows () - 1);

        size = win->size();
      }
      else // now fallback to hard defaults ;)
      {
        // first try global app config
        KConfigGroup cg( KGlobal::config(), "MainWindow" );
        size.setWidth (cg.readEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ));
        size.setHeight (cg.readEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ));

        if (size.isEmpty())
          size = QSize (qMin (700, desk.width()), qMin(480, desk.height()));
      }

      resize (size);
    }
  }

  // start session restore if needed
  startRestore (sconfig, sgroup);

  m_mainWindow = new Kate::MainWindow (this);

  // setup most important actions first, needed by setupMainWindow
  setupImportantActions ();

  // setup the most important widgets
  setupMainWindow();

  // setup the actions
  setupActions();

  setStandardToolBarMenuEnabled( true );
  setXMLFile( "kateui.rc" );
  createShellGUI ( true );

  //kDebug() << "****************************************************************************" << sconfig;

  // register mainwindow in app
  KateApp::self()->addMainWindow (this);

  // enable plugin guis
  KatePluginManager::self()->enableAllPluginsGUI (this, sconfig);

  // caption update
  for (uint i = 0; i < KateDocManager::self()->documents(); i++)
    slotDocumentCreated (KateDocManager::self()->document(i));

  connect(KateDocManager::self(), SIGNAL(documentCreated(KTextEditor::Document*)), this, SLOT(slotDocumentCreated(KTextEditor::Document*)));

  readOptions();

  if (sconfig)
    m_viewManager->restoreViewConfiguration (KConfigGroup(sconfig, sgroup) );

  finishRestore ();

  fileOpenRecent->loadEntries( KConfigGroup(sconfig, "Recent Files" ) );

  setAcceptDrops(true);

  connect(KateSessionManager::self(), SIGNAL(sessionChanged()), this, SLOT(updateCaption()));

  connect(this,SIGNAL(sigShowPluginConfigPage(Kate::PluginConfigPageInterface *,uint)),this,SLOT(showPluginConfigPage(Kate::PluginConfigPageInterface *,uint)));

  
}