Пример #1
0
WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
    : QWidget()
    , p_QupZilla(mainClass)
    , m_locationBar(locationBar)
    , m_pinned(false)
    , m_inspectorVisible(false)
{
    m_layout = new QVBoxLayout(this);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(0);

    m_view = new WebView(p_QupZilla, this);
    m_view.data()->setLocationBar(locationBar);
    m_layout->addWidget(m_view.data());

    setLayout(m_layout);
    setAutoFillBackground(true); // We don't want this transparent

    connect(m_view.data(), SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
    connect(m_view.data(), SIGNAL(iconChanged()), m_locationBar.data(), SLOT(siteIconChanged()));
    connect(m_view.data(), SIGNAL(loadStarted()), m_locationBar.data(), SLOT(clearIcon()));
    connect(m_view.data(), SIGNAL(loadFinished(bool)), m_locationBar.data(), SLOT(siteIconChanged()));
    connect(m_view.data(), SIGNAL(showUrl(QUrl)), m_locationBar.data(), SLOT(showUrl(QUrl)));
    connect(m_view.data(), SIGNAL(rssChanged(bool)), m_locationBar.data(), SLOT(showRSSIcon(bool)));
    connect(m_view.data()->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool)));
    connect(m_locationBar.data(), SIGNAL(loadUrl(QUrl)), m_view.data(), SLOT(load(QUrl)));
}
Пример #2
0
dtkSearchField::dtkSearchField(QWidget *parent) : QWidget(parent)
{
    QLineEdit *lineEdit = new QLineEdit(this);
    connect(lineEdit, SIGNAL(textChanged(QString)),
            this, SIGNAL(textChanged(QString)));
    connect(lineEdit, SIGNAL(editingFinished()),
            this, SIGNAL(editingFinished()));
    connect(lineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(setText(QString)));

    QToolButton *clearButton = new QToolButton(this);
    QPixmap clearIcon(QString(":/Qocoa/qsearchfield_nonmac.png"));
    clearButton->setIcon(QIcon(clearIcon));
    clearButton->setIconSize(clearIcon.size());
    clearButton->setFixedSize(clearIcon.size());
    clearButton->setStyleSheet("border: none;");
    clearButton->hide();
    connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));

    d = new dtkSearchFieldPrivate(this, lineEdit, clearButton);

    lineEdit->setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(d->clearButtonPaddedWidth()));
    const int width = qMax(lineEdit->minimumSizeHint().width(), d->clearButtonPaddedWidth());
    const int height = qMax(lineEdit->minimumSizeHint().height(), d->clearButtonPaddedHeight());
    lineEdit->setMinimumSize(width, height);

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->addWidget(lineEdit);
}
Пример #3
0
LocationBar::LocationBar(QupZilla* mainClass)
    : LineEdit(mainClass)
    , p_QupZilla(mainClass)
    , m_webView(0)
    , m_pasteAndGoAction(0)
    , m_clearAction(0)
    , m_rssIconVisible(false)
    , m_holdingAlt(false)
    , m_loadProgress(0)
    , m_progressVisible(false)
    , m_forcePaintEvent(false)
    , m_inlineCompletionVisible(false)
    , m_popupClosed(false)
{
    setObjectName("locationbar");
    setDragEnabled(true);

    m_bookmarkIcon = new BookmarksIcon(this);
    m_goIcon = new GoIcon(this);
    m_rssIcon = new RssIcon(this);
    m_siteIcon = new SiteIcon(p_QupZilla, this);
    m_autofillIcon = new AutoFillIcon(this);
    DownIcon* down = new DownIcon(this);

    // RTL Support
    // if we don't add 'm_siteIcon' by following code, then we should use suitable padding-left value
    // but then, when typing RTL text the layout dynamically changed and within RTL layout direction
    // padding-left is equivalent to padding-right and vice versa, and because style sheet is
    // not changed dynamically this create padding problems.
    addWidget(m_siteIcon, LineEdit::LeftSide);

    addWidget(m_autofillIcon, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_rssIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(down, LineEdit::RightSide);

    m_completer.setLocationBar(this);
    connect(&m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString)));
    connect(&m_completer, SIGNAL(completionActivated()), this, SLOT(urlEnter()));
    connect(&m_completer, SIGNAL(popupClosed()), this, SLOT(completionPopupClosed()));

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
    connect(down, SIGNAL(clicked(QPoint)), &m_completer, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText()));
    connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), SLOT(onMessage(Qz::AppMessageType,bool)));

    loadSettings();
    clearIcon();

    // Hide icons by default
    hideGoButton();
    m_rssIcon->hide();
    m_autofillIcon->hide();

    QTimer::singleShot(0, this, SLOT(updatePlaceHolderText()));
}
Пример #4
0
void LocationBar::siteIconChanged()
{
    QIcon icon_ = m_webView->icon();

    if (icon_.isNull()) {
        clearIcon();
    }
    else {
        m_siteIcon->setIcon(QIcon(icon_.pixmap(16, 16)));
    }
}
    void update (const File& root,
                 const DirectoryContentsList::FileInfo* const fileInfo,
                 const int index_,
                 const bool highlighted_) throw()
    {
        thread.removeTimeSliceClient (this);

        if (highlighted_ != highlighted
             || index_ != index)
        {
            index = index_;
            highlighted = highlighted_;
            repaint();
        }

        File newFile;
        String newFileSize;
        String newModTime;

        if (fileInfo != 0)
        {
            newFile = root.getChildFile (fileInfo->filename);
            newFileSize = File::descriptionOfSizeInBytes (fileInfo->fileSize);
            newModTime = fileInfo->modificationTime.formatted (T("%d %b '%y %H:%M"));
        }

        if (newFile != file
             || fileSize != newFileSize
             || modTime != newModTime)
        {
            file = newFile;
            fileSize = newFileSize;
            modTime = newModTime;

            isDirectory = fileInfo != 0 && fileInfo->isDirectory;
            repaint();

            clearIcon();
        }

        if (file != File::nonexistent
            && icon == 0 && ! isDirectory)
        {
            updateIcon (true);

            if (icon == 0)
                thread.addTimeSliceClient (this);
        }
    }
Пример #6
0
LocationBar::LocationBar(QupZilla* mainClass)
    : LineEdit()
    , p_QupZilla(mainClass)
    , m_webView(0)
    , m_menu(new QMenu(this))
    , m_pasteAndGoAction(0)
    , m_clearAction(0)
    , m_holdingAlt(false)
{
    setObjectName("locationbar");

    m_bookmarkIcon = new BookmarkIcon(p_QupZilla);
    m_goIcon = new GoIcon(this);
    m_rssIcon = new RssIcon(this);
    m_rssIcon->setToolTip(tr("Add RSS from this page..."));
    m_siteIcon = new SiteIcon(this);
    DownIcon* down = new DownIcon(this);

    addWidget(down, LineEdit::RightSide);
    addWidget(m_bookmarkIcon, LineEdit::RightSide);
    addWidget(m_goIcon, LineEdit::RightSide);
    addWidget(m_rssIcon, LineEdit::RightSide);

    setWidgetSpacing(0);

    m_locationCompleter = new LocationCompleter();
    setCompleter(m_locationCompleter);

//    LocationPopup* com = new LocationPopup(this);
//    connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show()));

    connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
    connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString)));
    connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), this, SLOT(urlEnter()));
    connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo()));
    connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
    connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked()));
    connect(down, SIGNAL(clicked(QPoint)), this, SLOT(showMostVisited()));
    connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));

    clearIcon();
    updatePlaceHolderText();
}
Пример #7
0
void iconTitleUpdate (int isdir, const char* name) {
	writeRow (0,name);
	writeRow (1,"");
	writeRow (2,"");
	writeRow (3,"");

	if (isdir) {
		// text
		writeRow (2,"[directory]");
		// icon
		clearIcon();
	} else if(strlen(name) >= 5 && strcasecmp(name + strlen(name) - 5, ".argv") == 0) {
		// look through the argv file for the corresponding nds file
		FILE    *fp;
		char    *line = NULL, *p = NULL;
		size_t  size = 0;
		ssize_t rc;

		// open the argv file
		fp = fopen(name,"rb");
		if(fp == NULL) {
			writeRow(2, "(can't open file!)");
			clearIcon();
			fclose(fp); return;
		}

		// read each line
		while((rc = __getline(&line, &size, fp)) > 0) {
			// remove comments
			if((p = strchr(line, '#')) != NULL)
				*p = 0;

			// skip leading whitespace
			for(p = line; *p && isspace((int)*p); ++p)
			  ;

			if(*p)
				break;
		}

		// done with the file at this point
		fclose(fp);

		if(p && *p) {
			// we found an argument
			struct stat st;

			// truncate everything after first argument
			strtok(p, "\n\r\t ");

			if(strlen(p) < 4 || strcasecmp(p + strlen(p) - 4, ".nds") != 0) {
				// this is not an nds file!
				writeRow(2, "(invalid argv file!)");
				clearIcon();
			} else {
				// let's see if this is a file or directory
				rc = stat(p, &st);
				if(rc != 0) {
					// stat failed
					writeRow(2, "(can't find argument!)");
					clearIcon();
				} else if(S_ISDIR(st.st_mode)) {
					// this is a directory!
					writeRow(2, "(invalid argv file!)");
					clearIcon();
				} else {
					iconTitleUpdate(false, p);
				}
			}
		} else {
			writeRow(2, "(no argument!)");
			clearIcon();
		}
		// clean up the allocated line
		free(line);
	} else {
		// this is an nds file!
		FILE *fp;
		unsigned int Icon_title_offset;
		int ret;

		// open file for reading info
		fp=fopen (name,"rb");
		if (fp==NULL) {
			// text
			writeRow (2,"(can't open file!)");
			// icon
			clearIcon();
			fclose (fp); return;
		}

		ret=fseek (fp, offsetof(tNDSHeader, bannerOffset), SEEK_SET);
		if (ret==0)
			ret=fread (&Icon_title_offset, sizeof(int), 1, fp); // read if seek succeed
		else
			ret=0;  // if seek fails set to !=1

		if (ret!=1) {
			// text
			writeRow (2,"(can't read file!)");
			// icon
			clearIcon();
			fclose (fp); return;
		}

		if (Icon_title_offset==0) {
			// text
			writeRow (2,"(no title/icon)");
			// icon
			clearIcon();
			fclose (fp); return;
		}

		ret=fseek (fp,Icon_title_offset,SEEK_SET);
		if (ret==0)
			ret=fread (&banner, sizeof(banner), 1, fp); // read if seek succeed
		else
			ret=0;  // if seek fails set to !=1

		if (ret!=1) {
			// text
			writeRow (2,"(can't read icon/title!)");
			// icon
			clearIcon();
			fclose (fp); return;
		}

		// close file!
		fclose (fp);

		// turn unicode into ascii (kind of)
		// and convert 0x0A into 0x00
		int i;
		char *p = (char*)banner.titles[0];
		for (i = 0; i < sizeof(banner.titles[0]); i = i+2) {
			if ((p[i] == 0x0A) || (p[i] == 0xFF))
				p[i/2] = 0;
			else
				p[i/2] = p[i];
		}

		// text
		for(i = 0; i < 3; ++i) {
			writeRow (i+1, p);
			p += strlen(p)+1;
		}

		// icon
		DC_FlushAll();
		dmaCopy(banner.icon,    sprite,         sizeof(banner.icon));
		dmaCopy(banner.palette, SPRITE_PALETTE, sizeof(banner.palette));
	}
}