void TabView::emitTabChanged(int index)
{
    Q_UNUSED(index);

    if (count() == 0) {
        m_pLastTab = nullptr;

        emit tabTitleChanged("");
        emit tabModified(false);
        emit tabChanged(nullptr, nullptr);

        return;
    }

    auto pCurrentTab = qobject_cast<Tab *>(currentWidget());

    if (m_pLastTab != pCurrentTab) {
        if (pCurrentTab != nullptr) {
            if (m_pLastTab != nullptr)
                disconnectTab(m_pLastTab);

            connectTab(pCurrentTab);

            emit tabTitleChanged(pCurrentTab->title());
            emit tabModified(pCurrentTab->isModified() || pCurrentTab->isNew());
            emit tabChanged(m_pLastTab, pCurrentTab);
        }

        m_pLastTab = pCurrentTab;
    }
}
void TabView::updateSnippetNameDataLanguageID(int snippetID)
{
    if (snippetID < 1)
        return;

    const auto nTabIndex = snippetTabIndex(snippetID);

    if (nTabIndex >= 0 && nTabIndex < count()) {
        if (auto pTab = qobject_cast<Tab*>(widget(nTabIndex))) {
            auto pTabSnippet = pTab->snippet();

            if (!pTabSnippet)
                return;

            qDebug() << Q_FUNC_INFO;

            const auto bIsTabModified = pTab->isModified();
            auto strTitle = pTabSnippet->name();

            pTab->setTitle(strTitle);
            emit tabTitleChanged(strTitle);

            if (bIsTabModified)
                strTitle += "*";

            setTabText(nTabIndex, strTitle);
            setTabToolTip(nTabIndex, strTitle);

            emit tabModified(bIsTabModified);
        }
    }
}
void TabView::onSnippetUpdated(int snippetID)
{
    if (snippetID < 1)
        return;

    const auto nTabIndex = snippetTabIndex(snippetID);

    if (nTabIndex >= 0 && nTabIndex < count()) {
        if (auto pTab = qobject_cast<Tab*>(widget(nTabIndex))) {
            auto pTabSnippet = pTab->snippet();

            if (!pTabSnippet)
                return;

            qDebug() << Q_FUNC_INFO;

            const auto strTitle = pTabSnippet->name();

            pTab->setTitle(strTitle);
            setTabText(nTabIndex, strTitle);
            setTabToolTip(nTabIndex, strTitle);

            disconnectTab(pTab);
            pTab->updateContent();
            connectTab(pTab);

            pTab->setModified(false);

            emit tabModified(false);
            emit tabTitleChanged(strTitle);
        }
    }
}
void TabView::onTabContentChanged()
{
    if (auto pCurrentTab = qobject_cast<Tab *>(currentWidget())) {
        pCurrentTab->setModified(true);

        if (pCurrentTab->isNew())
            emit tabModified(true);
        else {
            if (auto pTabSnippet = pCurrentTab->snippet()) {
                const auto strTitle = QString{"%1*"}.arg(pTabSnippet->name());
                pCurrentTab->setTitle(pTabSnippet->name());

                const auto nIndex = currentIndex();

                setTabText(nIndex, strTitle);
                setTabToolTip(nIndex, strTitle);

                pTabSnippet->setModified(true);

                emit tabTitleChanged(pTabSnippet->name());
                emit tabModified(true);
                emit tabContentChanged(pTabSnippet->id(), true);
            }
        }
    }
}
Example #5
0
/*=========================================================================
  setPath 
=========================================================================*/
void KFileBrowser::setPath (const QString &_path)
  {
  QString path;
  if (_path != "")
    path = _path;
  else
    path = homeDir;

  QDir dir(path, "*", QDir::DirsFirst);
  if (dir.isReadable())
    {
    emit statusUpdate (tr("Scanning folder..."));
    list->clear();
    QStringList entries = dir.entryList();
    QStringList::ConstIterator it = entries.constBegin();
    int count = 0;
    while (it != entries.constEnd()) 
      {
      if (*it != "." && *it != "..")
        {
        QListWidgetItem *item = new QListWidgetItem(*it, list);
        item->setIcon (getIconForFile (path + "/" + *it));
        //QSize size (200, 50);
        //item->setSizeHint (size);
        count++;
        }
      ++it;
      }
    this->path = dir.canonicalPath();
    pathDisplay->setText (this->path);
    QString title;
    if (this->path == "/")
      title = tr("Files: ") + "/"; 
    else
      title = tr("Files: ") + QFileInfo(this->path).fileName();
    emit tabTitleChanged ((QWidget *)this, &title);
    setViewMode (viewMode);
    if (count == 0)
      emit statusUpdate (tr("Folder empty"));
    else if (count == 1)
      emit statusUpdate (QString::number (count) + " " + tr("item") 
        + " " + tr("in folder"));
    else
      emit statusUpdate (QString::number (count) + " " + tr("items") 
        + " " + tr("in folder"));
    }
   else
    {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Critical);
    msgBox.setText("Can't read directory");
    msgBox.exec();
    }
  }
Example #6
0
void EditorWindow::loadConfigTab(ConfigDocument* doc)
{
    for(int i = 0; i < ui->editorTabs->count(); i++)
    {
        TabContent* current = dynamic_cast<TabContent*>
                              (ui->editorTabs->widget(i));
        if(current->file() == doc->file())
        {
            ui->editorTabs->setCurrentIndex(i);
            doc->deleteLater();
            return;
        }
    }

    addTab(doc);
    ui->editorTabs->setCurrentWidget(doc);

    QObject::connect(doc, SIGNAL(titleChanged(QString)),
                     this, SLOT(tabTitleChanged(QString)));
}
Example #7
0
// --- NEW TAB ---
// Open a new browser tab at the end of the tab bar.
void MainWindow::newTab() {
    qDebug("Loading new tab...");
    //QMessageBox msgBox;
    wv = new WFWebView();
    //connect(wv, SIGNAL(loadFinished(bool)), this, SLOT(diagnoseLoad(bool)));
    connect(wv->page()->mainFrame(), SIGNAL(loadFinished(bool)),
            this, SLOT(diagnoseLoad(bool)));
    connect(wv, SIGNAL(titleChanged(QString)),
            this, SLOT(tabTitleChanged(QString)));
    if (wv == 0) {
        qDebug("WV is null");
        return;
    }

    wv->page()->setNetworkAccessManager(nam);
    /*QWebSettings* ws = wv->settings();
    ws->setAttribute(QWebSettings::PluginsEnabled, true);
    ws->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    ws->setIconDatabasePath(icondb);*/
    wv->page()->setForwardUnsupportedContent(true); // enable downloads
    connect(wv->page(), SIGNAL(unsupportedContent(QNetworkReply*)),
            this, SLOT(downloadContent(QNetworkReply*))); // set up slot
    connect(wv->page(), SIGNAL(downloadRequested(QNetworkRequest)),
            this, SLOT(downloadContent(QNetworkRequest))); // context menu call
    connect(wv->page(), SIGNAL(linkHovered(QString,QString,QString)),
            this, SLOT(linkHovered(QString,QString,QString)));
    qDebug("Settings changed.");
    int index = tabWidget->count();
    ++index;
    index = tabWidget->insertTab(index, wv, tr("New Tab"));
    qDebug("Inserted tab.");
    addressBar->setText("");
    //addressBar->setFocus(Qt::OtherFocusReason);
    gotoAddressBar();
    tabWidget->setCurrentIndex(index);
    setWindowTitle("WildFox");
}
Example #8
0
void UIImageOverview::setTabTitle(QString s) {
    emit tabTitleChanged(this, s);
}