void MainDialogImpl::loaded(QString id){ if(sender()==sys) { tray->connected(); disconnect(sender(),0,this,0); rtc = new RTorrentClient(parent()); //update rate value connect(rtc,SIGNAL(changeUpRate(double)), tray,SIGNAL(getUpRate(double))); connect(rtc,SIGNAL(changeDownRate(double)), tray,SIGNAL(getDownRate(double))); //set new rate limit value connect(tray,SIGNAL(setUploadRate(int)), rtc,SLOT(setUploadRate(int))); connect(tray,SIGNAL(setDownloadRate(int)), rtc,SLOT(setDownloadRate(int))); //update rate limit value connect(rtc,SIGNAL(changeUploadRate(int)), tray,SIGNAL(getUploadRate(int))); connect(rtc,SIGNAL(changeDownloadRate(int)), tray,SIGNAL(getDownloadRate(int))); //connect update on show/hide event connect(tray,SIGNAL(menuShow()), rtc, SLOT(fullUpdate())); connect(tray,SIGNAL(menuShow()), rtc, SLOT(enableAutoUpdate())); connect(tray,SIGNAL(menuHide()), rtc, SLOT(disableAutoUpdate())); //------- connect(rtc,SIGNAL(updated(QString)), this,SLOT(loaded(QString))); } QSettings settings; QString view = settings.value("view","incomplete").toString(); if(sender()==rtc) { disconnect(sender(),0,this,0); rtc->using_views << view; rtc->loadUsingViews(); connect(rtc->torrents[view],SIGNAL(updated(QString)), this,SLOT(loaded(QString))); } if(id == view){ disconnect(sender(),0,this,0); int tc = rtc->torrents[view]->count(); for(int i = 0; i < tc; i++) tray->addTorrent(&((*rtc->torrents[view])[i])); } }
void Menu::menuShowHide() { m_isMenuVisible ? menuHide() : menuShow(); m_isMenuVisible = !m_isMenuVisible; }
TrayMenu::TrayMenu(QObject *parent) : QObject(parent) { tray = new QSystemTrayIcon(QIcon(":/img/update.png"),this); tray->show(); //Create menu menu = new QMenu(tr("rTorrent client"),0); //create separator //add rate control QWidget * rate_control = new QWidget(menu); QVBoxLayout * vlayout = new QVBoxLayout(rate_control); // UP SECTION QHBoxLayout * hlayout = new QHBoxLayout(); QSpinBox * spinUp = new QSpinBox(rate_control); InfoLabel * lbl_up = new InfoLabel(rate_control); QLabel * lbl = new QLabel(rate_control); lbl->setPixmap(QPixmap(":/img/up.png")); hlayout->addWidget(lbl); hlayout->addWidget(lbl_up); #if QT_VERSION >= 0x040403 hlayout->addSpacerItem(new QSpacerItem(40, 20, QSizePolicy::Expanding)); #endif hlayout->addWidget(spinUp); lbl_up->setText(tr("%1 kb/s")); spinUp->setMaximum (10*1024); spinUp->setSuffix (tr("kb/s")); //spinUp->setPrefix (tr("Up ")); vlayout->addLayout(hlayout); //DOWN SECTION hlayout = new QHBoxLayout(); QSpinBox * spinDown = new QSpinBox(rate_control); InfoLabel * lbl_down = new InfoLabel(rate_control); lbl = new QLabel(rate_control); lbl->setPixmap(QPixmap(":/img/down.png")); hlayout->addWidget(lbl); hlayout->addWidget(lbl_down); #if QT_VERSION >= 0x040403 hlayout->addSpacerItem(new QSpacerItem(40, 20, QSizePolicy::Expanding)); #endif hlayout->addWidget(spinDown); lbl_down->setText(tr("%1 kb/s")); spinDown->setMaximum (10*1024); spinDown->setSuffix (tr("kb/s")); //spinDown->setPrefix (tr("Down ")); vlayout->addLayout(hlayout); //insert control QWidgetAction * waction = new QWidgetAction(menu); waction->setDefaultWidget(rate_control); menu->addAction(waction); menu->addSeparator(); no_torrent = menu->addAction(tr("No torrents")); no_torrent->setDisabled(true); sep = menu->addSeparator(); //set new limit rate value connect(spinUp,SIGNAL(valueChanged(int)), this,SIGNAL(setUploadRate(int))); connect(spinDown,SIGNAL(valueChanged(int)), this,SIGNAL(setDownloadRate(int))); //update limit rate value connect(this,SIGNAL(getUploadRate(int)), spinUp,SLOT(setValue(int))); connect(this,SIGNAL(getDownloadRate(int)), spinDown,SLOT(setValue(int))); //update rate value connect(this,SIGNAL(getUpRate(double)), lbl_up,SLOT(setParam(double))); connect(this,SIGNAL(getDownRate(double)), lbl_down,SLOT(setParam(double))); //create settings item QAction * settings = menu->addAction(QIcon(":/img/gear.png"),tr("Settings")); connect(settings,SIGNAL(triggered(bool)), this, SLOT(openSettings(bool))); //create status item status = new QAction(QIcon(":/img/state2.png"),tr("Disconnected"),menu); menu->addAction(status); tray->setContextMenu(menu); //create exit item QAction * exit = menu->addAction(QIcon(":/img/exit.png"),tr("Exit")); //connect menu show connect(menu,SIGNAL(aboutToShow()), this,SIGNAL(menuShow())); connect(menu,SIGNAL(aboutToHide()), this,SIGNAL(menuHide())); //connect exit connect(exit,SIGNAL(triggered(bool)), this,SIGNAL(exitClicked(bool))); }
void CarPI::_displayMenuHide() { emit menuHide(); }