예제 #1
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    setWindowTitle(tr("Text Editor"));
    resize(700, 400);
    move(50, 50);

    tabs = new TabWidget(this);
    setCentralWidget(tabs);
    tabs->setTabsClosable(true);
    connect(tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
    connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
    connect(tabs, SIGNAL(textDropped(QString)), this, SLOT(textDropped(QString)));

    QStatusBar *sBar = new QStatusBar(this);
    setStatusBar(sBar);

    set = new QSettings("settings.ini", QSettings::IniFormat);
    QList<RecentFilesItem> files =  RecentFiles().allItems();
    QFileIconProvider *pvd = new QFileIconProvider();

    QMenuBar *bar = new QMenuBar(this);
    setMenuBar(bar);
    QMenu *mFile = bar->addMenu(tr("&File"));
    QMenu *mEdit = bar->addMenu(tr("&Edit"));
    QMenu *mView = bar->addMenu(tr("&View"));
    QMenu *mTool = bar->addMenu(tr("&Tool"));
    QMenu *mHelp = bar->addMenu(tr("&Help"));
    QAction *aNew   = mFile->addAction(QIcon::fromTheme("document-new"), tr("New"), this, SLOT(newTab()));
    QAction *aOpen  = mFile->addAction(QIcon::fromTheme("document-open"), tr("Open"), this, SLOT(open()));
    QMenu *mRecents = mFile->addMenu(QIcon::fromTheme(""), tr("Recently used"));
    foreach(RecentFilesItem file, files)
    {
        qDebug() << file.path();
        if(file.mimeType().startsWith("text/"))
            mRecents->addAction(QIcon(), file.path(), this, SLOT(openRecent()));
        if(mRecents->actions().count() == 5)
            break;
    }
예제 #2
0
void MyQLineEdit::dropEvent(QDropEvent *event)
{
    QString str = text();

    if (event->mimeData()->hasText())
    {
        QString text = event->mimeData()->text();
        setText(text);
    }

    event->acceptProposedAction();

    emit textDropped(str);
}
예제 #3
0
파일: LineEdit.cpp 프로젝트: GDXN/Natron
void
LineEdit::dropEvent(QDropEvent* e)
{
    if ( !e->mimeData()->hasUrls() ) {
        return;
    }

    QList<QUrl> urls = e->mimeData()->urls();
    QString path;
    if (urls.size() > 0) {
        path = urls.at(0).path();
    }
    if ( !path.isEmpty() ) {
        setText(path);
        emit textDropped();
    }
}
예제 #4
0
파일: LineEdit.cpp 프로젝트: haebler/Natron
void
LineEdit::dropEvent(QDropEvent* e)
{
    if ( !e->mimeData()->hasUrls() ) {
        return;
    }

    QList<QUrl> urls = e->mimeData()->urls();
    QString path;
    if (urls.size() > 0) {
        path = QtCompat::toLocalFileUrlFixed( urls.at(0) ).path();
    }
    if ( !path.isEmpty() ) {
        setText(path);
        Q_EMIT textDropped();
    }
}
예제 #5
0
void LineEditWidget::dropEvent(QDropEvent *event)
{
	if (m_selectionStart >= 0)
	{
		const int selectionEnd(m_selectionStart + event->mimeData()->text().length());
		int dropPosition(cursorPositionAt(event->pos()));

		if (dropPosition < m_selectionStart || dropPosition > selectionEnd)
		{
			if (dropPosition > selectionEnd)
			{
				dropPosition -= event->mimeData()->text().length();
			}

			setSelection(m_selectionStart, event->mimeData()->text().length());
			del();
			setCursorPosition(dropPosition);
			insert(event->mimeData()->text());
		}
	}
	else if (m_dropMode == ReplaceDropMode || m_dropMode == ReplaceAndNotifyDropMode)
	{
		selectAll();
		del();
		insert(event->mimeData()->text());

		if (m_dropMode == ReplaceAndNotifyDropMode)
		{
			emit textDropped(event->mimeData()->text());
		}
	}
	else
	{
		QLineEdit::dropEvent(event);
	}
}
예제 #6
0
		optionChanged(SettingsManager::AddressField_ShowBookmarkIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowBookmarkIconOption));
		optionChanged(SettingsManager::AddressField_ShowFeedsIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowFeedsIconOption));
		optionChanged(SettingsManager::AddressField_ShowUrlIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowUrlIconOption));

		m_lineEdit->setPlaceholderText(tr("Enter address or search…"));

		connect(SettingsManager::getInstance(), SIGNAL(valueChanged(int,QVariant)), this, SLOT(optionChanged(int,QVariant)));

		if (toolBar->getIdentifier() != ToolBarsManager::NavigationBar)
		{
			connect(toolBar, SIGNAL(windowChanged(Window*)), this, SLOT(setWindow(Window*)));
		}
	}

	connect(this, SIGNAL(activated(QString)), this, SLOT(openUrl(QString)));
	connect(m_lineEdit, SIGNAL(textDropped(QString)), this, SLOT(handleUserInput(QString)));
	connect(m_completionModel, SIGNAL(completionReady(QString)), this, SLOT(setCompletion(QString)));
	connect(BookmarksManager::getModel(), SIGNAL(modelModified()), this, SLOT(updateBookmark()));
	connect(HistoryManager::getTypedHistoryModel(), SIGNAL(modelModified()), this, SLOT(updateLineEdit()));
}

void AddressWidget::changeEvent(QEvent *event)
{
	ComboBoxWidget::changeEvent(event);

	switch (event->type())
	{
		case QEvent::LanguageChange:
			if (!m_isUsingSimpleMode)
			{
				m_lineEdit->setPlaceholderText(tr("Enter address or search…"));
예제 #7
0
	m_lineEdit->setCompleter(m_completer);
	m_lineEdit->setStyleSheet(QLatin1String("QLineEdit {background:transparent;}"));

	ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parent);

	if (toolBar && toolBar->getIdentifier() != ToolBarsManager::NavigationBar)
	{
		connect(toolBar, SIGNAL(windowChanged(Window*)), this, SLOT(setWindow(Window*)));
	}

	connect(SearchesManager::getInstance(), SIGNAL(searchEnginesModified()), this, SLOT(storeCurrentSearchEngine()));
	connect(SearchesManager::getInstance(), SIGNAL(searchEnginesModelModified()), this, SLOT(restoreCurrentSearchEngine()));
	connect(SettingsManager::getInstance(), SIGNAL(valueChanged(QString,QVariant)), this, SLOT(optionChanged(QString,QVariant)));
	connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChanged(int)));
	connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(queryChanged(QString)));
	connect(m_lineEdit, SIGNAL(textDropped(QString)), this, SLOT(sendRequest(QString)));
	connect(m_completer, SIGNAL(activated(QString)), this, SLOT(sendRequest(QString)));

	setWindow(window);
}

void SearchWidget::changeEvent(QEvent *event)
{
	QComboBox::changeEvent(event);

	if (event->type() == QEvent::LanguageChange && itemData(currentIndex(), Qt::AccessibleDescriptionRole).toString().isEmpty())
	{
		m_lineEdit->setPlaceholderText(tr("Search using %1").arg(currentData(Qt::UserRole).toString()));
	}
}