Exemplo n.º 1
0
void CasperAppWindow::on_activated(const QString &text) {
  if (text == "+") {
    if (Casper::ServiceList::Get()->GetActiveService().getName().isEmpty())
      qFatal("can't be empty");

    ctx->mWindowPtr->m_service_list->setCurrentText(
        Casper::ServiceList::Get()->GetActiveService().getName());

    // Casper::Client::Get()->RollbackDNS();
    ConfigureDialog *dialog = new ConfigureDialog(this);
    dialog->show();
    return;
  }
  qDebug() << Q_FUNC_INFO << "[ui] [activated]" << text;
  qDebug() << Q_FUNC_INFO << "[ui] [activated] [primary]"
           << Casper::ServiceList::Get()->GetService(text).getPrimary();

  ctx->mWindowPtr->m_service_btn->setChecked(false);
  ctx->mWindowPtr->m_service_btn->setChecked(true);

  Casper::ServiceList::Get()->SetActiveService(text);

  ctx->mWindowPtr->m_service_list->setCurrentText(
      Casper::ServiceList::Get()->GetActiveService().getName());
}
Exemplo n.º 2
0
void EditViewBase::slotConfigure()
{
    ConfigureDialog *configDlg =
        new ConfigureDialog(getDocument(), this);

    configDlg->show();
}
Exemplo n.º 3
0
void Clock::configure()
{
    ConfigureDialog dlg;
    dlg.setShowSecondsHand(mShowSeconds);
    if (dlg.exec())
    {
        mShowSeconds = dlg.showSecondsHand();
        startClock();
        update();
    }
    save();
}
void ConfigurePrinterInterface::ConfigurePrinter(const QString &destName)
{
    if (!m_uis.contains(destName)) {
        // Reserve this since the CUPS call might take a long time
        m_uis[destName] = 0;

        QStringList att;
        att << KCUPS_PRINTER_NAME;
        att << KCUPS_PRINTER_TYPE;
        // Get destinations with these attributes
        KCupsRequest *request = new KCupsRequest;
        request->getPrinters(att);
        request->waitTillFinished();

        bool found = false;
        KCupsPrinter printer;
        KCupsPrinters printers = request->printers();
        for (int i = 0; i < printers.size(); i++) {
            if (printers.at(i).name() == destName) {
                printer = printers.at(i);
                found = true;
                break;
            }
        }
        request->deleteLater();

        if (found) {
            ConfigureDialog *ui = new ConfigureDialog(printer.name(), printer.isClass());
            connect(m_updateUi, SIGNAL(timeout()),
                    ui, SLOT(update()));
            connect(ui, SIGNAL(finished()),
                    this, SLOT(RemovePrinter()));
            ui->show();
            m_uis[printer.name()] = ui;
        } else {
            // Remove the reservation
            m_uis.remove(destName);

            // if no destination was found and we aren't showing
            // a queue quit the app
            if (m_uis.isEmpty()) {
                 emit quit();
            }
            return;
        }
    }

    // Check it it's not reserved
    if (m_uis.value(destName)) {
        KWindowSystem::forceActiveWindow(m_uis.value(destName)->winId());
    }
}
Exemplo n.º 5
0
void ConfigItem::show()
{
    ConfigureDialog *dlg = static_cast<ConfigureDialog*>(listView()->topLevelWidget());
    if (m_widget == NULL){
        m_widget = getWidget(dlg);
        if (m_widget == NULL)
            return;
        dlg->wnd->addWidget(m_widget, id() ? id() : defId++);
        dlg->wnd->setMinimumSize(dlg->wnd->sizeHint());
        QObject::connect(dlg, SIGNAL(applyChanges()), m_widget, SLOT(apply()));
    }
    dlg->showUpdate(type() == CLIENT_ITEM);
    dlg->wnd->raiseWidget(m_widget);
}
Exemplo n.º 6
0
void ConfigItem::show()
{
	ConfigureDialog *dlg = static_cast<ConfigureDialog*>(treeWidget()->topLevelWidget());
    if (m_widget == NULL)
	{
        m_widget = getWidget(dlg);
        if (m_widget == NULL)
            return;
        m_id = dlg->wnd->addWidget(m_widget/*, id() ? id() : defId++*/);
        dlg->wnd->setMinimumSize(dlg->wnd->sizeHint());
        QObject::connect(dlg, SIGNAL(applyChanges()), m_widget, SLOT(apply()));
        QTimer::singleShot(50, dlg, SLOT(repaintCurrent()));
    }
    dlg->showUpdate(type() == CLIENT_ITEM);
    dlg->wnd->setCurrentWidget(m_widget);
}
Exemplo n.º 7
0
CasperAppWindow::CasperAppWindow(QWidget *parent)
    : QMainWindow(parent), ctx(new PrivateAppContext) {
  ctx->mWindowPtr->setupUi(this);
  setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
  ctx->mWindowPtr->toolBar->setFloatable(false);
  ctx->mWindowPtr->toolBar->setMovable(false);
  ctx->mWindowPtr->toolBar->setContextMenuPolicy(Qt::NoContextMenu);
  ctx->mWindowPtr->toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
  ctx->mWindowPtr->toolBar->addAction(
      QIcon(":/casper/artwork/casper_ui_toolbar_settings.svg"), "Settings");

#ifdef Q_OS_WIN
  setMinimumSize(211, 250);
  setMaximumSize(211, 250);
  setWindowTitle("Casper DNS");
  setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
#endif
  ctx->mServiceListPtr = Casper::ServiceList::Get();
  ctx->mServiceListPtr->Init();

  connect(ctx->mServiceListPtr, &Casper::ServiceList::service_added, this,
          [this]() {});

  UpdateServiceList();

  ctx->mWindowPtr->m_service_list->setCurrentText(
      Casper::ServiceList::Get()->GetActiveService().getName());

  connect(ctx->mWindowPtr->m_service_btn, &UIButton::toggled, this,
          [this](bool checked) {
    if (checked) {
      UpdateSystemDNS();
    } else {
      ctx->mWindowPtr->m_service_btn->setButtonActionState(
          UIButton::kButtonActionInactive);

      Casper::Client::Get()->RollbackDNS();
      // ctx->mWindowPtr->dns_status->setText("DNS DISABLED");
      // statusBar()->showMessage(tr("OFF"));
    }
  });

  connect(ctx->mWindowPtr->m_service_list, SIGNAL(activated(QString)), this,
          SLOT(on_activated(QString)));
  connect(ctx->mWindowPtr->m_service_list, SIGNAL(highlighted(QString)), this,
          SLOT(on_highligted(QString)));

  connect(Casper::ServiceList::Get(), &Casper::ServiceList::service_added, this,
          [this](const QString &name) { UpdateServiceList(); });

  connect(Casper::ServiceList::Get(), &Casper::ServiceList::service_removed,
          this, [this](const QString &name) {
    for (int i = 0;
         i < Casper::ServiceList::Get()->GetCurrentServiceList().count(); i++) {
      if (ctx->mWindowPtr->m_service_list->itemText(i) == name) {
        ctx->mWindowPtr->m_service_list->removeItem(i);
        break;
      }
    }
  });

  connect(ctx->mWindowPtr->toolBar, &QToolBar::actionTriggered, this,
          [this](QAction *action) {
    if (!action)
      return;
    ConfigureDialog *dialog = new ConfigureDialog(this);
    dialog->show();
  });
}
Exemplo n.º 8
0
ConfigureDialog *ConfigureDialog::createAndShow(QSettings *settings, QWidget *parent)
{
    ConfigureDialog *dlg = new ConfigureDialog(settings, parent);
    dlg->exec();
    return dlg;
}