コード例 #1
0
void WifiIconTimer::timerCallback() {
  if(!launcherComponent) { return; }
    
  for( auto button : launcherComponent->topButtons->buttons ) {
    if (button->getName() == "WiFi") {
      Image wifiIcon;
      const auto& conAp = getWifiStatus().connectedAccessPoint();
      
      // wifi on and connected
      if (getWifiStatus().isConnected() && conAp) {
        // 0 to 100
        float sigStrength = std::max(0, std::min(99, conAp->signalStrength));
        // don't include the wifi-off icon as a bin
        int iconBins = launcherComponent->wifiIconImages.size() - 2;
        int idx = round( ( iconBins * (sigStrength)/100.0f) );
        DBG(__func__ << ": accessing icon " << idx);
        wifiIcon = launcherComponent->wifiIconImages[idx];
      }
      // wifi on but no connection
      else if (getWifiStatus().isEnabled()) {
        wifiIcon = launcherComponent->wifiIconImages[0];
      }
      // wifi off
      else {
        wifiIcon = launcherComponent->wifiIconImages.getLast();
      }
      
      button->setImages(false, false, true,
                        wifiIcon, 1.0f, Colours::transparentWhite, // normal
                        wifiIcon, 1.0f, Colours::transparentWhite, // over
                        wifiIcon, 0.5f, Colours::transparentWhite, // down
                        0);
    }
  }
}
コード例 #2
0
void WifiCategoryItemComponent::disableWifiActions() {
  spinner->show();
  icon->setVisible(false);
  
  button->setEnabled(getWifiStatus().isEnabled());
  toggle->setEnabled(false);
  
  updateButtonText();
  toggle->setToggleState(getWifiStatus().isEnabled(), NotificationType::dontSendNotification);
}
コード例 #3
0
WifiCategoryItemComponent::WifiCategoryItemComponent() :
  SettingsCategoryItemComponent("wifi"),
  spinner(new WifiSpinner("SettingsWifiSpinner"))
{
  iconDrawable =
      Drawable::createFromImageFile(assetFile("wifiIcon.png"));
  icon->setImages(iconDrawable);
  bool isEnabled = getWifiStatus().isEnabled();
  toggle->setToggleState(isEnabled, NotificationType::dontSendNotification);
  button->setEnabled(isEnabled);
  addChildComponent(spinner);
  updateButtonText();
}
コード例 #4
0
void WifiCategoryItemComponent::updateButtonText() {
  const auto &status = getWifiStatus();
  if (status.isEnabled()) {
    if (status.isConnected() && status.connectedAccessPoint()) {
      button->setText(status.connectedAccessPoint()->ssid);
    }
    else {
      button->setText("Not Connected");
    }
  } else {
    button->setText("WiFi Off");
  }
}
コード例 #5
0
SettingsPageComponent::SettingsPageComponent(LauncherComponent* lc) {
  bgColor = Colour(0xffd23c6d);
  bgImage = createImageFromFile(assetFile("settingsBackground.png"));
  mainPage = new Component();
  addAndMakeVisible(mainPage);
  mainPage->toBack();
  ChildProcess child{};

  /* Adding the personalize button */
  advancedPage = new AdvancedSettingsPage(lc);
  advanced = new TextButton("Advanced Settings");
  advanced->addListener(this);
  addAndMakeVisible(advanced);
  
  brightness = 8;
  #if JUCE_LINUX
     // Get initial brightness value
     if(child.start("cat /sys/class/backlight/backlight/brightness")) {
    	String result{child.readAllProcessOutput()};
	brightness = result.getIntValue();
     };
  #endif


  volume = 90;
  
  #if JUCE_LINUX
    // Get initial volume value
    StringArray cmd{ "amixer","sget","Power Amplifier" };
    if(child.start(cmd)) {
      const String result (child.readAllProcessOutput());
      int resultIndex = result.indexOf("[")+1;
      child.waitForProcessToFinish (5 * 1000);
      char buff[4];
      for (int i = 0; i<4; i++) {
	      char c = result[resultIndex+i];
	      if( c >= '0' && c <= '9' ) {
		       buff[i]=c;
      	} else {
		     buff[i]=(char)0;
      	}
      }
      String newVol = String(buff);
      volume = newVol.getIntValue();
    }
  #endif

  ScopedPointer<Drawable> brightLo = Drawable::createFromImageFile(assetFile("brightnessIconLo.png"));
  ScopedPointer<Drawable> brightHi = Drawable::createFromImageFile(assetFile("brightnessIconHi.png"));
  screenBrightnessSlider =
      ScopedPointer<IconSliderComponent>(new IconSliderComponent(*brightLo, *brightHi));
  screenBrightnessSlider->addListener(this);
  screenBrightnessSlider->slider->setValue(1+(brightness-0.09)*10);

  ScopedPointer<Drawable> volLo =
      Drawable::createFromImageFile(assetFile("volumeIconLo.png"));
  ScopedPointer<Drawable> volHi =
      Drawable::createFromImageFile(assetFile("volumeIconHi.png"));
  volumeSlider = ScopedPointer<IconSliderComponent>(new IconSliderComponent(*volLo, *volHi));
  volumeSlider->addListener(this);
  volumeSlider->slider->setValue(volume);

  // create back button
  backButton = createImageButton(
                                 "Back", createImageFromFile(assetFile("backIcon.png")));
  backButton->addListener(this);
  backButton->setAlwaysOnTop(true);
  addAndMakeVisible(backButton);

  wifiCategoryItem = new WifiCategoryItemComponent();
  wifiCategoryItem->button->addListener(this);
  addAndMakeVisible(wifiCategoryItem);
  getWifiStatus().addListener(wifiCategoryItem);

  addAndMakeVisible(screenBrightnessSlider);
  addAndMakeVisible(volumeSlider);

  wifiPage = new SettingsPageWifiComponent();
}
コード例 #6
0
void WifiCategoryItemComponent::enabledStateChanged(bool enabled) {
  updateButtonText();
  
  enabled ? getWifiStatus().setEnabled() : getWifiStatus().setDisabled();
}