Exemplo n.º 1
0
MainWindow::MainWindow()
{
    setUnifiedTitleAndToolBarOnMac( true );

    QStatusBar* status = new QStatusBar( this );
    PlaybackControlsWidget* pcw = new PlaybackControlsWidget( status );

    //FIXME: this code is duplicated in the audioscrobbler app too
    //In order to compensate for the sizer grip on the bottom right
    //of the window, an empty QWidget is added as a spacer.
    QSizeGrip* sg = status->findChild<QSizeGrip *>();
    if( sg ) {
        int gripWidth = sg->sizeHint().width();
        QWidget* w = new QWidget( status );
        w->setFixedWidth( gripWidth );
        status->addWidget( w );
    }

    //Seemingly the only way to get a central widget in a QStatusBar
    //is to add an empty widget either side with a stretch value.
    status->addWidget( new QWidget( status), 1 );
    status->addWidget( pcw );
    status->addWidget( new QWidget( status), 1 );

    setStatusBar( status );

    MainWidget* mw;

    QWidget* w = new QWidget();
    
    new QVBoxLayout( w );
    w->layout()->addWidget(mw = new MainWidget());

    m_messageBar = new MessageBar( this );

    connect(mw, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));

    AuthenticatedUser user;
    connect(user.getFriends(), SIGNAL(finished()), mw, SLOT(onUserGotFriends()));
    connect(user.getTopTags(), SIGNAL(finished()), mw, SLOT(onUserGotTopTags()));
    connect(user.getPlaylists(), SIGNAL(finished()), mw, SLOT(onUserGotPlaylists()));
    connect(user.getRecentStations(), SIGNAL(finished()), mw, SLOT(onUserGotRecentStations()));

    setCentralWidget( w );

    finishUi();

    //todo: bury this:
    menuBar()->addMenu("Normania")->addAction( tr("RQL"), mw, SLOT(rawrql()), QKeySequence(tr("Ctrl+r")) );

    m_messageBar->raise();
}
Exemplo n.º 2
0
bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
#ifdef WIN32
    if (o->inherits("QSizeGrip")){
        QSizeGrip *grip = static_cast<QSizeGrip*>(o);
        QMouseEvent *me;
        switch (e->type()){
        case QEvent::MouseButtonPress:
            me = static_cast<QMouseEvent*>(e);
            p = me->globalPos();
            s = grip->topLevelWidget()->size();
            return true;
        case QEvent::MouseMove:
            me = static_cast<QMouseEvent*>(e);
            if (me->state() != LeftButton)
                break;
            QWidget *tlw = grip->topLevelWidget();
            QRect rc = tlw->geometry();
            if (tlw->testWState(WState_ConfigPending))
                break;
            QPoint np(me->globalPos());
            int w = np.x() - p.x() + s.width();
            int h = np.y() - p.y() + s.height();
            if ( w < 1 )
                w = 1;
            if ( h < 1 )
                h = 1;
            QSize ms(tlw->minimumSizeHint());
            ms = ms.expandedTo(minimumSize());
            if (w < ms.width())
                w = ms.width();
            if (h < ms.height())
                h = ms.height();
            if (!(GetWindowLongA(tlw->winId(), GWL_EXSTYLE) & WS_EX_APPWINDOW)){
                int dc = GetSystemMetrics(SM_CYCAPTION);
                int ds = GetSystemMetrics(SM_CYSMCAPTION);
                tlw->setGeometry(rc.left(), rc.top() + dc - ds, w, h);
            }else{
                tlw->resize(w, h);
            }
            MSG msg;
            while (PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
            return true;
        }
    }
    if (e->type() == QEvent::ChildInserted){
        QChildEvent *ce = static_cast<QChildEvent*>(e);
        if (ce->child()->inherits("QSizeGrip"))
            ce->child()->installEventFilter(this);
    }
#endif
    if (e->type() == QEvent::ChildRemoved){
        QChildEvent *ce = static_cast<QChildEvent*>(e);
        list<QWidget*>::iterator it;
        for (it = statusWidgets.begin(); it != statusWidgets.end(); ++it){
            if (*it == ce->child()){
                statusWidgets.erase(it);
                break;
            }
        }
        if (statusWidgets.size() == 0){
            statusBar()->hide();
            setGrip();
        }
    }
    return QMainWindow::eventFilter(o, e);
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_Configurator(this),
    update_Timer(this)
{
    QObject::connect(&update_Timer, SIGNAL(timeout()), this, SLOT(UpdateLabels()));
    ui->setupUi(this);
    //ui->toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
    this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    //Resize Option
    // QGridLayout is already in *.ui file
    // Using gridLayout here which is the outer layout
    QSizeGrip * sizeGrip = new QSizeGrip(this);
    ui->gridLayout->addWidget(sizeGrip, 0,0,10,10,Qt::AlignBottom | Qt::AlignRight);
    sizeGrip->setStyleSheet("background: url(''); width: 16px; height: 16px;");

    QObject::connect(ui->btnTransparency, SIGNAL(clicked(bool)), this, SLOT(EnableTransparency(bool)));
    QObject::connect(ui->btnHelp, SIGNAL(clicked()), this, SLOT(LinkToWebsite()));
    QObject::connect(ui->btnConfig, SIGNAL(clicked()), &m_Configurator, SLOT(exec()));

    ScreenRecorder* screenRecorder = new ScreenRecorder;
    DmgMeter* dmgMeter = &screenRecorder->GetDmgMeter();
    screenRecorder->moveToThread(&m_ScreenRecorderThread);

    Ui::Configurator* uiConfig = m_Configurator.ui;
    dmgMeter->moveToThread(&m_ScreenRecorderThread);

    QObject::connect(&m_ScreenRecorderThread, SIGNAL(finished()), screenRecorder, SLOT(deleteLater()));
    QObject::connect(&m_ScreenRecorderThread, SIGNAL(started()), screenRecorder, SLOT(StartRecording()));
    QObject::connect(screenRecorder, SIGNAL(RequestInfoUpdate(QString)), ui->labelInfo, SLOT(setText(QString)));
    QObject::connect(dmgMeter, SIGNAL(RequestTimeUpdate(int)), this, SLOT(UpdateTime(int)));
    QObject::connect(dmgMeter, SIGNAL(RequestDmgUpdate(unsigned long long)), this, SLOT(UpdateDmg(unsigned long long)));
    QObject::connect(dmgMeter, SIGNAL(RequestDpsUpdate(int)), this, SLOT(UpdateDps(int)));
    QObject::connect(dmgMeter, SIGNAL(RequestMaxDmgUpdate(int)), this, SLOT(UpdateMaxDmg(int)));
    QObject::connect(ui->btnReset, SIGNAL(clicked()), dmgMeter, SLOT(Reset()));
    QObject::connect(ui->btnAutoReset, SIGNAL(triggered(bool)), dmgMeter, SLOT(SetIsAutoResetting(bool)));
    QObject::connect(uiConfig->comboBoxScreenshots, SIGNAL(currentIndexChanged(QString)), screenRecorder, SLOT(SetScreenshotsPerSecond(QString)));
    QObject::connect(uiConfig->comboBoxUpdates, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetUpdatesPerSecond(QString)));
    QObject::connect(uiConfig->comboBoxSecondsInCombat, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetSecondsInCombat(QString)));
    QObject::connect(uiConfig->comboBoxConsideredLines, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetConsideredLineCount(QString)));
    QObject::connect(uiConfig->pushButtonReset, SIGNAL(clicked(bool)), &m_Configurator, SLOT(RestoreDefaults()));

    dmgMeter->SetUpdatesPerSecond(uiConfig->comboBoxUpdates->currentText());
    dmgMeter->SetSecondsInCombat(uiConfig->comboBoxSecondsInCombat->currentText());
    dmgMeter->SetConsideredLineCount(uiConfig->comboBoxConsideredLines->currentText());

    m_ScreenRecorderThread.start();

    Settings::ReadSettings<QMainWindow>(this);

    // Start screenshot timer from separate thread
    const int oldIndex = uiConfig->comboBoxScreenshots->currentIndex();
    uiConfig->comboBoxScreenshots->setCurrentIndex((uiConfig->comboBoxScreenshots->currentIndex() + 1) % uiConfig->comboBoxScreenshots->count());
    uiConfig->comboBoxScreenshots->setCurrentIndex(oldIndex);

    socket = new QTcpSocket(this);


    connect(socket, SIGNAL(connected()),this, SLOT(connected()));
    connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected()));
    connect(socket, SIGNAL(readyRead()),this, SLOT(ready2Read()));

    connect(dmgMeter, SIGNAL(RequestNetWrite(char*)), this, SLOT(netWrite(char*)));

    qDebug() << "connecting to : " << HostIP << ":" << HostPort;

    // this is not blocking call

    // IP should be yours
    MyClientSlot=10; //no semi-handshake yet
    CurrentMeta=0;CurrentPos=0;
    int i;
    for (i=0;i<10;i++)
    {
        SlotDmg[i]=0;
        SlotDPS[i]=0;
        SlotAct[i]=0;
        SlotName[i][0]='\0';
    }
    AllDamageDone=0;
    hitCounter=0;
    critChance=0;
    critCounter=0;
    condiDmg=0;
    LastColor=0;

    socket->connectToHost(HostIP, HostPort);

    // we need to wait...
    if(!socket->waitForConnected(5000))
    {
        qDebug() << "Error: " << socket->errorString();
    }
    m_Dps=0;m_Dmg=0;m_Activity=0;
    update_Timer.start(1000);
}
Exemplo n.º 4
0
SettingsDialog::SettingsDialog(QObject *parent )
    : QObject( parent )
    , m_accountsWidgetUi( new Ui_Settings_Accounts )
    , m_accountsWidget( new QWidget )
    , m_collectionWidgetUi( new Ui_Settings_Collection )
    , m_collectionWidget( new QWidget )
    , m_advancedWidgetUi( new Ui_Settings_Advanced )
    , m_advancedWidget( new QWidget )
    , m_downloadsWidgetUi( new Ui_Settings_Downloads )
    , m_downloadsWidget( new QWidget )
    , m_staticHostSettings( 0 )
    , m_proxySettings( 0 )
    , m_restartRequired( false )
    , m_accountModel( 0 )
    , m_sipSpinner( 0 )
{
    m_accountsWidget->setFont( TomahawkUtils::systemFont() );
    m_collectionWidget->setFont( TomahawkUtils::systemFont() );
    m_advancedWidget->setFont( TomahawkUtils::systemFont() );
    m_downloadsWidget->setFont( TomahawkUtils::systemFont() );

    m_accountsWidgetUi->setupUi( m_accountsWidget );
    m_collectionWidgetUi->setupUi( m_collectionWidget );
    m_advancedWidgetUi->setupUi( m_advancedWidget );
    m_downloadsWidgetUi->setupUi( m_downloadsWidget );

    m_accountsWidgetUi->accountsFilterCombo->setFocusPolicy( Qt::NoFocus );
    m_dialog = new QToolbarTabDialog;




    TomahawkSettings* s = TomahawkSettings::instance();
    
// CHANGED
    m_advancedWidgetUi->checkBoxExitOnClose->setChecked( s->exitOnClose());


    m_advancedWidgetUi->checkBoxReporter->setChecked( s->crashReporterEnabled() );
    m_advancedWidgetUi->checkBoxHttp->setChecked( s->httpEnabled() );
    m_advancedWidgetUi->checkBoxListenApi->setChecked( s->httpBindAll() );
    m_advancedWidgetUi->checkBoxSongChangeNotifications->setChecked( s->songChangeNotificationEnabled() );

    //Network settings
    Tomahawk::Network::ExternalAddress::Mode mode = TomahawkSettings::instance()->externalAddressMode();
    if ( mode == Tomahawk::Network::ExternalAddress::Lan )
        m_advancedWidgetUi->lanOnlyRadioButton->setChecked( true );
    else if ( mode == Tomahawk::Network::ExternalAddress::Static )
        m_advancedWidgetUi->staticIpRadioButton->setChecked( true );
    else
        m_advancedWidgetUi->upnpRadioButton->setChecked( true );

    m_advancedWidgetUi->staticHostSettingsButton->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );

    bool useProxy = TomahawkSettings::instance()->proxyType() == QNetworkProxy::Socks5Proxy;
    m_advancedWidgetUi->enableProxyCheckBox->setChecked( useProxy );
    m_advancedWidgetUi->proxyButton->setEnabled( useProxy );

    m_advancedWidgetUi->aclEntryClearButton->setEnabled( TomahawkSettings::instance()->aclEntries().size() > 0 );
    connect( m_advancedWidgetUi->aclEntryClearButton, SIGNAL( clicked( bool ) ), this, SLOT( aclEntryClearButtonClicked() ) );

#ifdef Q_OS_MAC
    // Avoid resize handles on sheets on osx
    m_proxySettings.setSizeGripEnabled( true );
    QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
    m_staticHostSettings.setSizeGripEnabled( true );
    p = m_staticHostSettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
#endif

    m_accountsWidgetUi->installFromFileBtn->setText( tr( "Install Plug-In..." ) );

    // Accounts
    AccountDelegate* accountDelegate = new AccountDelegate( this );
    m_accountsWidgetUi->accountsView->setItemDelegate( accountDelegate );
    m_accountsWidgetUi->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
    m_accountsWidgetUi->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    m_accountsWidgetUi->accountsView->setMouseTracking( true );

    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
    connect( accountDelegate, SIGNAL( update( QModelIndex ) ), m_accountsWidgetUi->accountsView, SLOT( update( QModelIndex ) ) );

    m_accountModel = new AccountModel( this );
    m_accountProxy = new AccountModelFilterProxy( m_accountModel );
    m_accountProxy->setSourceModel( m_accountModel );

    connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( errorInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( errorInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), SLOT( scrollTo( QModelIndex ) ) );

    m_accountsWidgetUi->accountsView->setModel( m_accountProxy );

    connect( m_accountsWidgetUi->installFromFileBtn, SIGNAL( clicked( bool ) ), SLOT( installFromFile() ) );
    connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );

    m_accountsWidgetUi->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( ResolverType ), ResolverType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( StatusPushType ), StatusPushType );

    connect( m_accountsWidgetUi->accountsFilterCombo, SIGNAL( activated( int ) ), SLOT( accountsFilterChanged( int ) ) );

    if ( !Servent::instance()->isReady() )
    {
        m_sipSpinner = new AnimatedSpinner( m_accountsWidgetUi->accountsView );
        m_sipSpinner->fadeIn();

        connect( Servent::instance(), SIGNAL( ready() ), SLOT( serventReady() ) );
    }

    // ADVANCED
    m_advancedWidgetUi->proxyButton->setVisible( true );

    m_collectionWidgetUi->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
    m_collectionWidgetUi->scannerTimeSpinBox->setValue( s->scannerTime() );
    m_collectionWidgetUi->enableEchonestCatalog->setChecked( s->enableEchonestCatalogs() );

    connect( m_collectionWidgetUi->checkBoxWatchForChanges, SIGNAL( clicked( bool ) ), SLOT( updateScanOptionsView() ) );

    if ( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() )
    {
        m_collectionWidgetUi->scanTimeLabel->show();
        m_collectionWidgetUi->scannerTimeSpinBox->show();
    }
    else
    {
        m_collectionWidgetUi->scanTimeLabel->hide();
        m_collectionWidgetUi->scannerTimeSpinBox->hide();
    }

/*    foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
    {
        m_collectionWidgetUi->dirTree->checkPath( dir, Qt::Checked );
    }*/
    m_collectionWidgetUi->pathListWidget->addItems( TomahawkSettings::instance()->scannerPaths() );

    const int buttonSize = TomahawkUtils::defaultFontHeight() * 2.5;
    m_collectionWidgetUi->addLibraryPathButton->setFixedSize( buttonSize, buttonSize );
    m_collectionWidgetUi->removeLibraryPathButton->setFixedSize( m_collectionWidgetUi->addLibraryPathButton->size() );

    connect( m_collectionWidgetUi->addLibraryPathButton, SIGNAL( clicked() ), SLOT( addLibraryPath() ) );
    connect( m_collectionWidgetUi->removeLibraryPathButton, SIGNAL( clicked() ), SLOT( removeLibraryPath() ) );

    int buttonsWidth = qMax( m_advancedWidgetUi->proxyButton->sizeHint().width(),
                             m_advancedWidgetUi->aclEntryClearButton->sizeHint().width() );
    m_advancedWidgetUi->proxyButton->setFixedWidth( buttonsWidth );
    m_advancedWidgetUi->aclEntryClearButton->setFixedWidth( buttonsWidth );

    m_downloadsWidgetUi->downloadsFolder->setText( TomahawkSettings::instance()->downloadsPath() );
    connect( m_downloadsWidgetUi->pickFolderButton, SIGNAL( clicked() ), SLOT( pickDownloadsPath() ) );

    m_downloadsFormats.insert( "MP3", tr( "MP3" ) );
    m_downloadsFormats.insert( "FLAC", tr( "FLAC" ) );
    m_downloadsFormats.insert( "M4A", tr( "M4A" ) );
    m_downloadsFormats.insert( "MP4", tr( "MP4" ) );
    foreach ( const QString& format, m_downloadsFormats.values() )
    {
        m_downloadsWidgetUi->preferredFormatComboBox->addItem( format );
    }
    int i = m_downloadsWidgetUi->preferredFormatComboBox->findText( m_downloadsFormats.value( TomahawkSettings::instance()->downloadsPreferredFormat() ) );
    if ( i < 0 )
        i = m_downloadsWidgetUi->preferredFormatComboBox->findText( "MP3" );
    m_downloadsWidgetUi->preferredFormatComboBox->setCurrentIndex( i );

#ifndef Q_OS_MAC
    m_advancedWidget->setMinimumSize( m_advancedWidget->sizeHint() );
    m_accountsWidget->setMinimumWidth( 500 );
#else
    m_accountsWidget->setContentsMargins( 6, 6, 6, 6 );
    m_accountsWidgetUi->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
    m_accountsWidgetUi->installFromFileBtn->setContentsMargins( 0, 0, 0, 0 );
    m_accountsWidget->setMinimumSize( 550, 400 );
    m_accountsWidgetUi->accountsView->setAttribute( Qt::WA_MacShowFocusRect, false );

    m_collectionWidget->setContentsMargins( 6, 6, 6, 6 );
    m_collectionWidget->setMinimumHeight( m_collectionWidgetUi->verticalLayout->sizeHint().height() + 20 );
    m_collectionWidgetUi->pathListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );

    m_advancedWidget->setContentsMargins( 6, 6, 6, 6 );
    m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() );
#endif

    // NOW PLAYING
// #ifdef Q_OS_MAC
//     ui->checkBoxEnableAdium->setChecked( s->nowPlayingEnabled() );
// #else
//     ui->checkBoxEnableAdium->hide();
// #endif

    m_dialog->addTab( m_accountsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AccountSettings ),
                      tr( "Plug-Ins" ), tr( "Configure the accounts and services used by Tomahawk "
                                             "to search and retrieve music, find your friends and "
                                             "update your status." ) );

    m_dialog->addTab( m_collectionWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::MusicSettings ),
                      tr( "Collection" ), tr( "Manage how Tomahawk finds music on your computer." ) );

    m_dialog->addTab( m_advancedWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AdvancedSettings ),
                      tr( "Advanced" ), tr( "Configure Tomahawk's advanced settings, including "
                                            "network connectivity settings, browser interaction "
                                            "and more." ) );

    m_dialog->addTab( m_downloadsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::DownloadsSettings ),
                      tr( "Downloads" ), tr( "Configure Tomahawk's integrated download manager." ) );

    m_dialog->setCurrentIndex( 0 );

    connect( m_advancedWidgetUi->staticHostSettingsButton, SIGNAL( clicked() ), SLOT( showStaticHostSettings() ) );
    connect( m_advancedWidgetUi->proxyButton,  SIGNAL( clicked() ), SLOT( showProxySettings() ) );
    connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->upnpRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->upnpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( toggleProxyEnabled() ) );
    connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );

    connect( m_dialog, SIGNAL( accepted() ), SLOT( saveSettings() ) );
    connect( m_dialog, SIGNAL( rejected() ), SLOT( onRejected() ) );
}
Exemplo n.º 5
0
FreqView::FreqView(int viewID_, QWidget *parent)
  : ViewWidget(viewID_, parent)
{
  View *view = gdata->view;

  //setCaption("Frequency View");

  Q3BoxLayout *mainLayout = new Q3VBoxLayout(this);
  mainLayout->setResizeMode(QLayout::SetNoConstraint);
  //QBoxLayout *topLayout = new QVBoxLayout(mainLayout);
  //QBoxLayout *rightLayout = new QVBoxLayout(mainLayout);
  //QBoxLayout *bottomLayout = new QHBoxLayout(mainLayout);


  QSplitter *splitter = new QSplitter(Qt::Vertical, this);
  QWidget *topWidget = new QWidget(splitter);
  //topSplitter->setOpaqueResize(true);
  Q3BoxLayout *topLayout = new Q3HBoxLayout(topWidget);
  Q3BoxLayout *topLeftLayout = new Q3VBoxLayout(topLayout);
  
  timeAxis = new TimeAxis(topWidget, gdata->leftTime(), gdata->rightTime(), true);
  timeAxis->setWhatsThis("The time in seconds");
  topLeftLayout->addWidget(timeAxis);
  
/*
  Q3Grid *freqFrame = new Q3Grid(1, topWidget);
  freqFrame->setFrameStyle(Q3Frame::WinPanel | Q3Frame::Sunken);
  //freqDrawWidget = new FreqDrawWidget(freqFrame);
  //freqDrawWidget->setFocusPolicy(Qt::NoFocus);
  freqWidgetGL = new FreqWidgetGL(freqFrame);
  freqWidgetGL->setFocusPolicy(Qt::NoFocus);
  topLeftLayout->addWidget(freqFrame);
*/
  QFrame *freqFrame = new QFrame;
  freqFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
  QVBoxLayout *freqFrameLayout = new QVBoxLayout;
  freqWidgetGL = new FreqWidgetGL(NULL);
  freqWidgetGL->setWhatsThis("The line represents the musical pitch of the sound. A higher pitch moves up, with note names shown at the left, with octave numbers. "
    "The black vertical line shows the current time. This line's position can be moved. "
    "Pitch-lines are drawn connected only because they change a small amount over a small time step. "
    "Note: This may cause semi-tone note changes appear to be joined. Clicking the background and dragging moves the view. "
    "Clicking a pitch-line selects it. Mouse-Wheel scrolls. Shift-Mouse-Wheel zooms");
  //freqWidgetGL = new FreqDrawWidget(NULL);
  freqFrameLayout->addWidget(freqWidgetGL);
  freqFrameLayout->setMargin(0);
  freqFrameLayout->setSpacing(0);
  freqFrame->setLayout(freqFrameLayout);
  topLeftLayout->addWidget(freqFrame);


  //Q3BoxLayout *topRightLayout = new Q3VBoxLayout(topLayout);
  QVBoxLayout *topRightLayout = new QVBoxLayout();
  
  freqWheelY = new QwtWheel(topWidget);
  freqWheelY->setOrientation(Qt::Vertical);
  freqWheelY->setWheelWidth(14);
  freqWheelY->setRange(1.6, 5.0, 0.001, 1);
  //freqWheelY->setValue(3.2);
  //view->setZoomFactorY(3.2);
  freqWheelY->setValue(view->logZoomY());
  QToolTip::add(freqWheelY, "Zoom pitch contour view vertically");
  topRightLayout->addSpacing(20);
  topRightLayout->addWidget(freqWheelY, 0);
  
  //Create the vertical scrollbar
  //vScrollBar = new MyScrollBar(0, toInt((view->topNote()-view->viewHeight())*view->stepY()), 20, toInt(view->viewHeight()*view->stepY()), toInt(view->viewBottom()*view->stepY()), Qt::Vertical, this);
  //vScrollBar = new MyScrollBar(0, gdata->topNote()-view->viewHeight(), 20, view->viewHeight(), view->viewBottom(), 20, Qt::Vertical, this);
  freqScrollBar = new MyScrollBar(0, gdata->topPitch()-view->viewHeight(), 0.5, view->viewHeight(), 0, 20, Qt::Vertical, topWidget);
  freqScrollBar->setValue(gdata->topPitch()-view->viewHeight()-view->viewBottom());
  topRightLayout->addWidget(freqScrollBar, 4);

  topLayout->addLayout(topRightLayout);

/*
  QPushButton *buttonPlusY = new QPushButton("+", topSplitter);
  buttonPlusY->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
  buttonPlusY->setFixedSize(15, 15);
  QToolTip::add(buttonPlusY, "Zoom in vertically");
  QPushButton *buttonMinusY = new QPushButton("-", topSplitter);
  buttonMinusY->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
  buttonMinusY->setFixedSize(15, 15);
  QToolTip::add(buttonMinusY, "Zoom out vertically");
*/  
  

  //------------bottom half------------------
  
  QWidget *bottomWidget = new QWidget(splitter);
  Q3BoxLayout *bottomLayout = new Q3VBoxLayout(bottomWidget);
  Q3BoxLayout *bottomTopLayout = new Q3HBoxLayout(bottomLayout);
  
/*
  Q3Grid *amplitudeFrame = new Q3Grid(1, bottomWidget);
  amplitudeFrame->setFrameStyle(Q3Frame::WinPanel | Q3Frame::Sunken);
  amplitudeWidget = new AmplitudeWidget(amplitudeFrame);
  bottomTopLayout->addWidget(amplitudeFrame);
*/
  QFrame *amplitudeFrame = new QFrame;
  amplitudeFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
  QVBoxLayout *amplitudeFrameLayout = new QVBoxLayout;
  amplitudeWidget = new AmplitudeWidget(NULL);
  amplitudeWidget->setWhatsThis("Shows the volume (or other parameters) at time lined up with the pitch above. Note: You can move the lines to change some thresholds.");
  amplitudeFrameLayout->addWidget(amplitudeWidget);
  amplitudeFrameLayout->setMargin(0);
  amplitudeFrameLayout->setSpacing(0);
  amplitudeFrame->setLayout(amplitudeFrameLayout);
  bottomTopLayout->addWidget(amplitudeFrame);

  Q3BoxLayout *bottomTopRightLayout = new Q3VBoxLayout(bottomTopLayout);
  
  amplitudeWheelY = new QwtWheel(bottomWidget);
  amplitudeWheelY->setOrientation(Qt::Vertical);
  amplitudeWheelY->setWheelWidth(14);
  //amplitudeWheelY->setRange(30, 150, 0.1, 1);
  amplitudeWheelY->setRange(0.2, 1.00, 0.01, 1);
  amplitudeWheelY->setValue(amplitudeWidget->range());
  QToolTip::add(amplitudeWheelY, "Zoom pitch contour view vertically");
  bottomTopRightLayout->addWidget(amplitudeWheelY, 0);
  
  //Create the vertical scrollbar
  //amplitudeScrollBar = new MyScrollBar(0, 150, 20, 80, 0, 20, Qt::Vertical, bottomWidget);
  amplitudeScrollBar = new MyScrollBar(0.0, 1.0-amplitudeWidget->range(), 0.20, amplitudeWidget->range(), 0, 20, Qt::Vertical, bottomWidget);
  bottomTopRightLayout->addWidget(amplitudeScrollBar, 4);
  
  Q3BoxLayout *bottomBottomLayout = new Q3HBoxLayout(bottomLayout);
/*
  QSpinBox *thresholdSpinBox = new QSpinBox(50, 100, 1, bottomWidget, "thresholdSpinBox");
  thresholdSpinBox->setSuffix("%");
  thresholdSpinBox->setFocusPolicy(Qt::NoFocus);
  thresholdSpinBox->setValue(gdata->getActiveIntThreshold());
  QToolTip::add(thresholdSpinBox, "Threshold used in choosing the octave");
  connect(thresholdSpinBox, SIGNAL(valueChanged(int)), gdata, SLOT(resetActiveIntThreshold(int)));
  //connect(thresholdSpinBox, SIGNAL(valueChanged(int)), freqDrawWidget, SLOT(update()));
  connect(thresholdSpinBox, SIGNAL(valueChanged(int)), freqWidgetGL, SLOT(update()));
  connect(gdata, SIGNAL(activeIntThresholdChanged(int)), thresholdSpinBox, SLOT(setValue(int)));
*/
  
  QComboBox *amplitudeModeComboBox = new QComboBox(bottomWidget, "amplitudeTypeModeBox");
  //static const char* amplitudeModeItems[] = { "RMS (Log)", "Peak Amplitude (Log)", "Peak Correlation", "Purity", "Changeness", 0 };
  //amplitudeModeComboBox->insertStrList(amplitudeModeItems);
  //amplitudeModeComboBox->insertStrList(amp_mode_names, NUM_AMP_MODES);
  amplitudeModeComboBox->setWhatsThis("Select different algorithm parameters to view in the bottom pannel");
  int j;
  QStringList s;
  for(j=0; j<NUM_AMP_MODES; j++) s << amp_mode_names[j];
  amplitudeModeComboBox->addItems(s);
  connect(amplitudeModeComboBox, SIGNAL(activated(int)), gdata, SLOT(setAmplitudeMode(int)));
  connect(amplitudeModeComboBox, SIGNAL(activated(int)), amplitudeWidget, SLOT(update()));

  QComboBox *pitchContourModeComboBox = new QComboBox(bottomWidget, "pitchContourModeComboBox");
  pitchContourModeComboBox->setWhatsThis("Select whether the Pitch Contour line fades in/out with clarity/loudness of the sound or is a solid dark line");
  //static const char* pitchContourModeItems[] = { "Clarity fading", "Note grouping", 0 };
  //pitchContourModeComboBox->insertStrList(pitchContourModeItems);
  s.clear();
  s << "Clarity fading" << "Note grouping";
  pitchContourModeComboBox->addItems(s);
  connect(pitchContourModeComboBox, SIGNAL(activated(int)), gdata, SLOT(setPitchContourMode(int)));
  //connect(pitchContourModeComboBox, SIGNAL(activated(int)), freqDrawWidget, SLOT(update()));
  connect(pitchContourModeComboBox, SIGNAL(activated(int)), freqWidgetGL, SLOT(update()));

  freqWheelX = new QwtWheel(bottomWidget);
  freqWheelX->setOrientation(Qt::Horizontal);
  freqWheelX->setWheelWidth(16);
  freqWheelX->setRange(0.5, 9.0, 0.001, 1);
  freqWheelX->setValue(2.0);
  QToolTip::add(freqWheelX, "Zoom horizontally");
  
  bottomBottomLayout->addStretch(2);
  //bottomBottomLayout->addWidget(thresholdSpinBox, 0);
  //bottomBottomLayout->addStretch(2);
  bottomBottomLayout->addWidget(amplitudeModeComboBox, 0);
  bottomBottomLayout->addStretch(2);
  bottomBottomLayout->addWidget(pitchContourModeComboBox, 0);
  bottomBottomLayout->addStretch(2);
  bottomBottomLayout->addWidget(freqWheelX, 1);
  bottomBottomLayout->addSpacing(16);
 

  
  //Create the horizontal scrollbar and +/- buttons
  //hScrollBar = new MyScrollBar(gdata->leftTime(), gdata->rightTime(), 0.1, view->viewWidth(), view->currentTime(), 10000, Qt::Horizontal, this);
/*  
  QPushButton *buttonPlusX = new QPushButton("+", this);
  buttonPlusX->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
  buttonPlusX->setFixedSize(15, 15);
  QToolTip::add(buttonPlusX, "Zoom in horizontal");
  QPushButton *buttonMinusX = new QPushButton("-", this);
  buttonMinusX->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
  buttonMinusX->setFixedSize(15, 15);
  QToolTip::add(buttonMinusX, "Zoom out horizontal");
*/

  //Create the resize grip. The thing in the bottom right hand corner
  QSizeGrip *sizeGrip = new QSizeGrip(bottomWidget);
  sizeGrip->setFixedSize(15, 15);
  //sizeGrip->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum, false));
  sizeGrip->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, false));
  bottomBottomLayout->addWidget(sizeGrip);
  
  //Actually add all the widgets into the widget layout
  //topLayout->addWidget(timeAxis);
  mainLayout->addWidget(splitter);
  //rightLayout->addWidget(buttonMinusY);
  //rightLayout->addWidget(buttonPlusY);
  //rightLayout->addWidget(vScrollBar);
  //bottomLayout->addWidget(buttonMinusX);
  //bottomLayout->addWidget(buttonPlusX);
  //mainLayout->addWidget(sizeGrip, 1, 1);
      
  //Setup all the signals and slots
  //vertical

  connect(freqScrollBar, SIGNAL(sliderMoved(double)), view, SLOT(changeViewY(double)));
  connect(freqScrollBar, SIGNAL(sliderMoved(double)), view, SLOT(doSlowUpdate()));

  connect(view, SIGNAL(viewBottomChanged(double)), freqScrollBar, SLOT(setValue(double)));
/*  connect(view, SIGNAL(scrollableYChanged(double)), freqScrollBar, SLOT(setMaxValue(double)));
  connect(view, SIGNAL(viewHeightChanged(double)), freqScrollBar, SLOT(setPageStep(double)));
*/
  connect(freqWheelY, SIGNAL(valueChanged(double)), view, SLOT(setZoomFactorY(double)));
  connect(view, SIGNAL(logZoomYChanged(double)), freqWheelY, SLOT(setValue(double)));
  //connect(view, SIGNAL(logZoomYChanged(double)), freqDrawWidget, SLOT(update()));
  
  //horizontal
  connect(freqWheelX, SIGNAL(valueChanged(double)), view, SLOT(setZoomFactorX(double)));
  connect(view, SIGNAL(logZoomXChanged(double)), freqWheelX, SLOT(setValue(double)));
  //connect(view, SIGNAL(logZoomXChanged(double)), view, SLOT(doSlowUpdate()));
  //connect(buttonPlusX, SIGNAL(clicked()), view, SLOT(viewZoomInX()));
  //connect(buttonMinusX, SIGNAL(clicked()), view, SLOT(viewZoomOutX()));
  connect(amplitudeWheelY, SIGNAL(valueChanged(double)), amplitudeWidget, SLOT(setRange(double)));
  //connect(amplitudeWidget, SIGNAL(dBRangeChanged(double)), amplitudeScrollBar, SLOT(setPageStep(double)));
  connect(amplitudeWheelY, SIGNAL(valueChanged(double)), amplitudeWidget, SLOT(update()));

  connect(amplitudeScrollBar, SIGNAL(sliderMoved(double)), amplitudeWidget, SLOT(setOffset(double)));
  connect(amplitudeScrollBar, SIGNAL(sliderMoved(double)), amplitudeWidget, SLOT(update()));

  connect(amplitudeWidget, SIGNAL(rangeChanged(double)), this, SLOT(setAmplitudeZoom(double)));
  connect(amplitudeWidget, SIGNAL(rangeChanged(double)), amplitudeWheelY, SLOT(setValue(double)));
  connect(amplitudeWidget, SIGNAL(offsetChanged(double)), amplitudeScrollBar, SLOT(setValue(double)));

/*
  connect(hScrollBar, SIGNAL(valueChanged(double)), view, SLOT(setCurrentTime(double)));
  connect(hScrollBar, SIGNAL(sliderMoved(double)), gdata, SLOT(updateActiveChunkTime(double)));
  connect(gdata, SIGNAL(leftTimeChanged(double)), hScrollBar, SLOT(setMinValue(double)));
  connect(gdata, SIGNAL(rightTimeChanged(double)), hScrollBar, SLOT(setMaxValue(double)));
  connect(view, SIGNAL(currentTimeChanged(double)), hScrollBar, SLOT(setValue(double)));
  connect(view, SIGNAL(viewWidthChanged(double)), hScrollBar, SLOT(setPageStep(double)));
*/
  //make the widgets get updated when the view changes
  //connect(gdata->view, SIGNAL(onSlowUpdate(double)), freqDrawWidget, SLOT(update()));
  connect(gdata->view, SIGNAL(onSlowUpdate(double)), freqWidgetGL, SLOT(update()));
  //connect(gdata->view, SIGNAL(onSlowUpdate(double)), amplitudeWidget, SLOT(update()));
  connect(gdata->view, SIGNAL(onSlowUpdate(double)), amplitudeWidget, SLOT(update()));
  //connect(gdata->view, SIGNAL(onSlowUpdate(double)), timeAxis, SLOT(update()));
  connect(gdata->view, SIGNAL(onSlowUpdate(double)), timeAxis, SLOT(update()));
  connect(gdata->view, SIGNAL(timeViewRangeChanged(double, double)), timeAxis, SLOT(setRange(double, double)));
}
Exemplo n.º 6
0
SettingsDialog::SettingsDialog(QObject *parent )
    : QObject( parent )
    , m_accountsWidgetUi( new Ui_Settings_Accounts )
    , m_accountsWidget( new QWidget )
    , m_collectionWidgetUi( new Ui_Settings_Collection )
    , m_collectionWidget( new QWidget )
    , m_advancedWidgetUi( new Ui_Settings_Advanced )
    , m_advancedWidget( new QWidget )
    , m_proxySettings( 0 )
    , m_rejected( false )
    , m_restartRequired( false )
    , m_accountModel( 0 )
    , m_sipSpinner( 0 )
{
    m_accountsWidgetUi->setupUi( m_accountsWidget );
    m_collectionWidgetUi->setupUi( m_collectionWidget );
    m_advancedWidgetUi->setupUi( m_advancedWidget );

    m_accountsWidgetUi->accountsFilterCombo->setFocusPolicy( Qt::NoFocus );

    m_dialog = new QToolbarTabDialog;

    TomahawkSettings* s = TomahawkSettings::instance();

    m_advancedWidgetUi->checkBoxReporter->setChecked( s->crashReporterEnabled() );
    m_advancedWidgetUi->checkBoxHttp->setChecked( s->httpEnabled() );
    m_advancedWidgetUi->checkBoxSongChangeNotifications->setChecked( s->songChangeNotificationEnabled() );
    #ifndef Q_OS_LINUX // no backends on OSX or Win so far
        m_advancedWidgetUi->checkBoxSongChangeNotifications->setVisible( false );
    #endif

    //Network settings
    TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
    if ( mode == TomahawkSettings::Lan )
        m_advancedWidgetUi->lanOnlyRadioButton->setChecked( true );
    else if ( mode == TomahawkSettings::Static )
        m_advancedWidgetUi->staticIpRadioButton->setChecked( true );
    else
        m_advancedWidgetUi->upnpRadioButton->setChecked( true );

    m_advancedWidgetUi->staticHostNamePortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
    m_advancedWidgetUi->staticHostName->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
    m_advancedWidgetUi->staticPort->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
    m_advancedWidgetUi->staticHostNameLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
    m_advancedWidgetUi->staticPortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );

    bool useProxy = TomahawkSettings::instance()->proxyType() == QNetworkProxy::Socks5Proxy;
    m_advancedWidgetUi->enableProxyCheckBox->setChecked( useProxy );
    m_advancedWidgetUi->proxyButton->setEnabled( useProxy );

    m_advancedWidgetUi->aclEntryClearButton->setEnabled( TomahawkSettings::instance()->aclEntries().size() > 0 );
    connect( m_advancedWidgetUi->aclEntryClearButton, SIGNAL( clicked( bool ) ), this, SLOT( aclEntryClearButtonClicked() ) );

#ifdef Q_WS_MAC
    // Avoid resize handles on sheets on osx
    m_proxySettings.setSizeGripEnabled( true );
    QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
#endif

    m_accountsWidgetUi->installFromFileBtn->setText( tr( "Install from file" ) );

    // Accounts
    AccountDelegate* accountDelegate = new AccountDelegate( this );
    m_accountsWidgetUi->accountsView->setItemDelegate( accountDelegate );
    m_accountsWidgetUi->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
    m_accountsWidgetUi->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    m_accountsWidgetUi->accountsView->setMouseTracking( true );

    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), this, SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
    connect( accountDelegate, SIGNAL( update( QModelIndex ) ), m_accountsWidgetUi->accountsView, SLOT( update( QModelIndex ) ) );

    m_accountModel = new AccountModel( this );
    m_accountProxy = new AccountModelFilterProxy( m_accountModel );
    m_accountProxy->setSourceModel( m_accountModel );

    connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( errorInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( errorInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) );

    m_accountsWidgetUi->accountsView->setModel( m_accountProxy );

    connect( m_accountsWidgetUi->installFromFileBtn, SIGNAL( clicked( bool ) ), this, SLOT( installFromFile() ) );
    connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );

    m_accountsWidgetUi->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( ResolverType ), ResolverType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( StatusPushType ), StatusPushType );

    connect( m_accountsWidgetUi->accountsFilterCombo, SIGNAL( activated( int ) ), this, SLOT( accountsFilterChanged( int ) ) );

    if ( !Servent::instance()->isReady() )
    {
        m_sipSpinner = new AnimatedSpinner( m_accountsWidgetUi->accountsView );
        m_sipSpinner->fadeIn();

        connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
    }

    // ADVANCED
    m_advancedWidgetUi->staticHostName->setText( s->externalHostname() );
    m_advancedWidgetUi->staticPort->setValue( s->externalPort() );
    m_advancedWidgetUi->proxyButton->setVisible( true );

    m_collectionWidgetUi->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
    m_collectionWidgetUi->scannerTimeSpinBox->setValue( s->scannerTime() );
    m_collectionWidgetUi->enableEchonestCatalog->setChecked( s->enableEchonestCatalogs() );

    connect( m_collectionWidgetUi->checkBoxWatchForChanges, SIGNAL( clicked( bool ) ), SLOT( updateScanOptionsView() ) );

    if ( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() )
    {
        m_collectionWidgetUi->scanTimeLabel->show();
        m_collectionWidgetUi->scannerTimeSpinBox->show();
    }
    else
    {
        m_collectionWidgetUi->scanTimeLabel->hide();
        m_collectionWidgetUi->scannerTimeSpinBox->hide();
    }

    foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
    {
        m_collectionWidgetUi->dirTree->checkPath( dir, Qt::Checked );
    }
Exemplo n.º 7
0
SettingsDialog::SettingsDialog( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui_StackedSettingsDialog )
    , m_proxySettings( this )
    , m_rejected( false )
    , m_accountModel( 0 )
    , m_sipSpinner( 0 )
{
    ui->setupUi( this );
    TomahawkSettings* s = TomahawkSettings::instance();

    TomahawkUtils::unmarginLayout( layout() );
    ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );

    ui->checkBoxReporter->setChecked( s->crashReporterEnabled() );
    ui->checkBoxHttp->setChecked( s->httpEnabled() );
    ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
    ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
    ui->checkBoxUpnp->setEnabled( !s->preferStaticHostPort() );

    createIcons();
#ifdef Q_WS_X11
    ui->listWidget->setFrameShape( QFrame::StyledPanel );
    ui->listWidget->setFrameShadow( QFrame::Sunken );
    setContentsMargins( 4, 4, 4, 4 );
#else
    setContentsMargins( 0, 4, 4, 4 );
#endif

#ifdef Q_WS_MAC
    ui->listWidget->setFixedWidth( 83 );
#endif

#ifdef Q_WS_MAC
    // Avoid resize handles on sheets on osx
    m_proxySettings.setSizeGripEnabled( true );
    QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
#endif

    // Accounts
    AccountDelegate* accountDelegate = new AccountDelegate( this );
    ui->accountsView->setItemDelegate( accountDelegate );
    ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
    ui->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    ui->accountsView->setMouseTracking( true );

    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), this, SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
    connect( accountDelegate, SIGNAL( update( QModelIndex ) ), ui->accountsView, SLOT( update( QModelIndex ) ) );

    m_accountModel = new AccountModel( this );
    m_accountProxy = new AccountModelFilterProxy( m_accountModel );
    m_accountProxy->setSourceModel( m_accountModel );

    connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) );

    ui->accountsView->setModel( m_accountProxy );

    connect( ui->installFromFileBtn, SIGNAL( clicked( bool ) ), this, SLOT( installFromFile() ) );
    connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );

    ui->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType );
    ui->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType );
    ui->accountsFilterCombo->addItem( accountTypeToString( ResolverType ), ResolverType );
    ui->accountsFilterCombo->addItem( accountTypeToString( StatusPushType ), StatusPushType );

    connect( ui->accountsFilterCombo, SIGNAL( activated( int ) ), this, SLOT( accountsFilterChanged( int ) ) );

    if ( !Servent::instance()->isReady() )
    {
        m_sipSpinner = new LoadingSpinner( ui->accountsView );
        m_sipSpinner->fadeIn();

        connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
    }

    // ADVANCED
    ui->staticHostName->setText( s->externalHostname() );
    ui->staticPort->setValue( s->externalPort() );
    ui->proxyButton->setVisible( true );

    ui->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
    ui->scannerTimeSpinBox->setValue( s->scannerTime() );
    ui->enableEchonestCatalog->setChecked( s->enableEchonestCatalogs() );

    connect( ui->checkBoxWatchForChanges, SIGNAL( clicked( bool ) ), SLOT( updateScanOptionsView() ) );

    if ( ui->checkBoxWatchForChanges->isChecked() )
    {
        ui->scanTimeLabel->show();
        ui->scannerTimeSpinBox->show();
    }
    else
    {
        ui->scanTimeLabel->hide();
        ui->scannerTimeSpinBox->hide();
    }

    foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
    {
        ui->dirTree->checkPath( dir, Qt::Checked );
    }
Exemplo n.º 8
0
SettingsDialog::SettingsDialog( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui_StackedSettingsDialog )
    , m_proxySettings( this )
    , m_rejected( false )
    , m_sipModel( 0 )
    , m_resolversModel( 0 )
{
    ui->setupUi( this );
    TomahawkSettings* s = TomahawkSettings::instance();

    ui->checkBoxHttp->setChecked( s->httpEnabled() );
    ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
    ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
    ui->checkBoxUpnp->setEnabled( !s->preferStaticHostPort() );

    createIcons();
#ifdef Q_WS_X11
    ui->listWidget->setFrameShape( QFrame::StyledPanel );
    ui->listWidget->setFrameShadow( QFrame::Sunken );
    setContentsMargins( 4, 4, 4, 4 );
#else
    ui->verticalLayout->removeItem( ui->verticalSpacer_3 );
#endif

#ifdef Q_WS_MAC
    // Avoid resize handles on sheets on osx
    m_proxySettings.setSizeGripEnabled( true );
    QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
#endif

    // SIP PLUGINS
    SipConfigDelegate* sipdel = new SipConfigDelegate( this );
    ui->accountsView->setItemDelegate( sipdel );
    ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );

    connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) );
    connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) );
    connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sipContextMenuRequest( QPoint ) ) );
    m_sipModel = new SipModel( this );
    ui->accountsView->setModel( m_sipModel );

    setupSipButtons();

    ui->staticHostName->setText( s->externalHostname() );
    ui->staticPort->setValue( s->externalPort() );

    ui->proxyButton->setVisible( true );

    // MUSIC SCANNER
    //FIXME: MULTIPLECOLLECTIONDIRS
    if ( s->scannerPaths().count() )
        ui->lineEditMusicPath_2->setText( s->scannerPaths().first() );
    else
    {
        ui->lineEditMusicPath_2->setText( QDesktopServices::storageLocation( QDesktopServices::MusicLocation ) );
    }

    // WATCH CHANGES
    // FIXME: QFileSystemWatcher is broken (as we know) and deprecated. Find another way.
    ui->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
    ui->checkBoxWatchForChanges->setVisible( false );

    // LAST FM
    ui->checkBoxEnableLastfm->setChecked( s->scrobblingEnabled() );
    ui->lineEditLastfmUsername->setText( s->lastFmUsername() );
    ui->lineEditLastfmPassword->setText(s->lastFmPassword() );
    connect( ui->pushButtonTestLastfmLogin, SIGNAL( clicked( bool) ), this, SLOT( testLastFmLogin() ) );

    // SCRIPT RESOLVER
    ui->removeScript->setEnabled( false );
    ResolverConfigDelegate* del = new ResolverConfigDelegate( this );
    connect( del, SIGNAL( openConfig( QString ) ), this, SLOT( openResolverConfig( QString ) ) );
    ui->scriptList->setItemDelegate( del );
    m_resolversModel = new ResolversModel( s->allScriptResolvers(), s->enabledScriptResolvers(), this );
    ui->scriptList->setModel( m_resolversModel );

    connect( ui->scriptList->selectionModel(), SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), this, SLOT( scriptSelectionChanged() ) );
    connect( ui->addScript, SIGNAL( clicked( bool ) ), this, SLOT( addScriptResolver() ) );
    connect( ui->removeScript, SIGNAL( clicked( bool ) ), this, SLOT( removeScriptResolver() ) );

    connect( ui->buttonBrowse_2, SIGNAL( clicked() ),  SLOT( showPathSelector() ) );
    connect( ui->proxyButton,  SIGNAL( clicked() ),  SLOT( showProxySettings() ) );
    connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
    connect( this,             SIGNAL( rejected() ), SLOT( onRejected() ) );

    ui->listWidget->setCurrentRow( 0 );
}