Esempio n. 1
0
int NetOpenPanel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = OpenPanel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateMRL(); break;
        case 1: updateCompleter(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
void FilePathWidget::updateCompleter()
{
	if (!m_completer)
	{
		FileSystemCompleterModel *model = new FileSystemCompleterModel(m_completer);
		model->setFilter(m_selectFile ? QDir::Files : QDir::AllDirs);

		m_completer = new QCompleter(this);
		m_completer->setModel(model);

		m_lineEdit->setCompleter(m_completer);

		m_completer->complete();

		disconnect(m_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(updateCompleter()));
	}
}
FilePathWidget::FilePathWidget(QWidget *parent) : QWidget(parent),
	m_lineEdit(new QLineEdit(this)),
	m_completer(NULL),
	m_selectFile(true)
{
	QPushButton *button = new QPushButton(tr("Browse…"), this);
	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->addWidget(m_lineEdit);
	layout->addWidget(button);
	layout->setContentsMargins(0, 0, 0, 0);

	setLayout(layout);
	setFocusPolicy(Qt::StrongFocus);
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

	connect(m_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(updateCompleter()));
	connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(pathChanged(QString)));
	connect(button, SIGNAL(clicked()), this, SLOT(selectPath()));
}
Esempio n. 4
0
MainWindow::MainWindow()
{
//QTime t = QTime::currentTime();
#ifndef KTIKZ_USE_KDE
	m_aboutDialog = 0;
	m_assistantController = 0;
#endif
	m_configDialog = 0;
	m_isModifiedExternally = false;
	m_insertAction = 0;

	s_mainWindowList.append(this);

#ifndef KTIKZ_USE_KDE
	QStringList themeSearchPaths;
	themeSearchPaths << QDir::homePath() + QLatin1String("/.local/share/icons/");
	themeSearchPaths << QIcon::themeSearchPaths();
	QIcon::setThemeSearchPaths(themeSearchPaths);
#endif

	setAttribute(Qt::WA_DeleteOnClose);
#ifdef KTIKZ_USE_KDE
	setObjectName(QLatin1String("ktikz#"));
	setWindowIcon(KIcon(QLatin1String("ktikz")));
	Action::setActionCollection(actionCollection());
#else
	setObjectName(QLatin1String("qtikz#") + QString::number(s_mainWindowList.size()));
	setWindowIcon(QIcon(QLatin1String(":/icons/qtikz-22.png")));
#endif

	setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
	setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
	setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
	setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);

//qCritical() << t.msecsTo(QTime::currentTime());
	m_tikzPreviewController = new TikzPreviewController(this);
//qCritical() << "TikzPreviewController" << t.msecsTo(QTime::currentTime());
	m_tikzEditorView = new TikzEditorView(this);
//qCritical() << "TikzEditorView" << t.msecsTo(QTime::currentTime());
	m_commandInserter = new TikzCommandInserter(this);
	m_tikzHighlighter = new TikzHighlighter(m_tikzEditorView->editor()->document());
	m_userCommandInserter = new UserCommandInserter(this);

	QWidget *mainWidget = new QWidget(this);
	QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
	mainLayout->setSpacing(0);
	mainLayout->setMargin(0);
	mainLayout->addWidget(m_tikzPreviewController->templateWidget());
	mainLayout->addWidget(m_tikzEditorView);

	m_logDock = new QDockWidget(this);
	m_logDock->setObjectName(QLatin1String("LogDock"));
	m_logDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	m_logDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	m_logDock->setWindowTitle(tr("&Messages"));
	addDockWidget(Qt::BottomDockWidgetArea, m_logDock);
	m_logTextEdit = new LogTextEdit;
	m_logTextEdit->setWhatsThis(tr("<p>The messages produced by "
	                               "LaTeX are shown here.  If your TikZ code contains errors, "
	                               "then a red border will appear and the errors will be "
	                               "highlighted.</p>"));
	m_logDock->setWidget(m_logTextEdit);

	m_previewDock = new QDockWidget(this);
	m_previewDock->setObjectName(QLatin1String("PreviewDock"));
	m_previewDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	m_previewDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	m_previewDock->setWindowTitle(tr("Previe&w"));
	m_previewDock->setWidget(m_tikzPreviewController->tikzPreview());
	addDockWidget(Qt::RightDockWidgetArea, m_previewDock);

	setCentralWidget(mainWidget);

	createActions();
#ifndef KTIKZ_USE_KDE
	createToolBars(); // run first in order to be able to add file/editToolBar->toggleViewAction() to the menu
	createMenus();
#endif
//qCritical() << "createMenus" << t.msecsTo(QTime::currentTime());
	createCommandInsertWidget(); // must happen after createMenus and before readSettings
	createStatusBar();

#ifdef KTIKZ_USE_KDE
	setupGUI(ToolBar | Keys | StatusBar | Save);
	setXMLFile(QLatin1String("ktikzui.rc"));
	createGUI();
	guiFactory()->addClient(this);
#endif
	setTabOrder(m_tikzPreviewController->templateWidget()->lastTabOrderWidget(), m_tikzEditorView->editor());

	connect(m_commandInserter, SIGNAL(showStatusMessage(QString,int)),
	        statusBar(), SLOT(showMessage(QString,int)));

	connect(m_tikzEditorView, SIGNAL(modificationChanged(bool)),
	        this, SLOT(setDocumentModified(bool)));
	connect(m_tikzEditorView, SIGNAL(cursorPositionChanged(int,int)),
	        this, SLOT(showCursorPosition(int,int)));
	connect(m_tikzEditorView, SIGNAL(showStatusMessage(QString,int)),
	        statusBar(), SLOT(showMessage(QString,int)));

	connect(m_tikzEditorView, SIGNAL(focusIn()),
	        this, SLOT(checkForFileChanges()));
	connect(m_tikzEditorView, SIGNAL(focusOut()),
	        this, SLOT(saveLastInternalModifiedDateTime()));

	connect(m_tikzPreviewController, SIGNAL(updateLog(QString,bool)),
	        m_logTextEdit, SLOT(updateLog(QString,bool)));
	connect(m_tikzPreviewController, SIGNAL(appendLog(QString,bool)),
	        m_logTextEdit, SLOT(appendLog(QString,bool)));
	connect(m_tikzPreviewController, SIGNAL(showMouseCoordinates(qreal,qreal,int,int)),
	        this, SLOT(showMouseCoordinates(qreal,qreal,int,int)));

	connect(m_userCommandInserter, SIGNAL(updateCompleter()),
	        this, SLOT(updateCompleter()));

	readSettings(); // must be run after defining tikzController and tikzHighlighter, and after creating the toolbars, and after the connects
//qCritical() << "readSettings()" << t.msecsTo(QTime::currentTime());

	setCurrentUrl(Url());
	setDocumentModified(false);
	saveLastInternalModifiedDateTime();
	m_tikzEditorView->editor()->setFocus();

	// delayed initialization
//	QTimer::singleShot(0, this, SLOT(init())); // this causes flicker at startup and init() is not executed in a separate thread anyway :(
	init();
//qCritical() << "mainwindow" << t.msecsTo(QTime::currentTime());
}