コード例 #1
0
ファイル: querywidget.cpp プロジェクト: callaa/KQueryBrowser
void QueryWidget::findInPage(bool forward)
{
	if(!m_find->isVisible())
		showSearch();

	QWebPage::FindFlags flags = QWebPage::FindWrapsAroundDocument;
	if(m_findui->casesensitive->isChecked())
		flags |= QWebPage::FindCaseSensitively;
	if(m_findui->highlightall->isChecked())
		flags |= QWebPage::HighlightAllOccurrences;
	if(!forward)
		flags |= QWebPage::FindBackward;

	QBrush text;
	if(m_view->findText(m_findui->findtext->text(), flags)) {
		// Found text
		text = KColorScheme(QPalette::Normal).foreground(KColorScheme::NormalText);
	} else {
		// Not found
		text = KColorScheme(QPalette::Normal).foreground(KColorScheme::NegativeText);
	}
	QPalette pal;
	pal.setBrush(QPalette::Text, text);
	m_findui->findtext->setPalette(pal);
}
コード例 #2
0
ファイル: DatabaseWidget.cpp プロジェクト: szsolt/keepassx
void DatabaseWidget::toggleSearch()
{
    if (m_entryView->inEntryListMode()) {
        closeSearch();
    }
    else {
        showSearch();
    }
}
コード例 #3
0
ファイル: mpdf.cpp プロジェクト: qihao/Lookshare-GUI
void Mpdf::searchClicked()
{
    if (searchView)
    {
        hideSearch();
    }
    else
    {
        showSearch();
    }
}
コード例 #4
0
ファイル: searchablewebview.cpp プロジェクト: leo8916/zeal
void SearchableWebView::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
    case Qt::Key_Slash:
        showSearch();
        event->accept();
        break;
    default:
        event->ignore();
        break;
    }
}
コード例 #5
0
EditorWidgetQSci::EditorWidgetQSci(QWidget *parent) : EditorWidget(parent)
{
    m_widget = new QWidget(parent);
    QVBoxLayout *l = new QVBoxLayout(m_widget);

    m_editor = new QsciScintilla(m_widget);
    m_editor->setMarginLineNumbers(QsciScintilla::NumberMargin, true);
    m_editor->setMarginWidth(QsciScintilla::NumberMargin, "12322");
    m_editor->setBraceMatching(QsciScintilla::SloppyBraceMatch);
    m_editor->setAutoCompletionSource(QsciScintilla::AcsAll);
    m_editor->setAutoCompletionThreshold(3);
    m_editor->setAutoIndent(true);
    m_editor->setIndentationsUseTabs(false);
    m_editor->setIndentationWidth(4);
    m_editor->setUtf8(true);
    m_editor->setEolMode(QsciScintilla::EolUnix);

    m_search_widget = new QWidget(m_widget);
    m_search_ui = new Ui::QSciSearchBar;
    m_search_ui->setupUi(m_search_widget);

    l->addWidget(m_editor, 1);
    l->addWidget(m_search_widget);

    m_search_widget->setVisible(false);
    setSearchBarReplaceVisible(false);

    m_canUndo = false;
    m_canRedo = false;

    QShortcut *find_s = new QShortcut(QKeySequence("Ctrl+F"), m_widget);
    QShortcut *replace_s = new QShortcut(QKeySequence("Ctrl+R"), m_widget);
    QShortcut *find_esc_s = new QShortcut(QKeySequence("Esc"), m_widget);

    connect(m_editor, SIGNAL(modificationChanged(bool)), SLOT(modified(bool)));
    connect(m_editor, SIGNAL(textChanged()),             SLOT(checkUndoRedo()));
    connect(m_search_ui->expandBtn, SIGNAL(clicked(bool)), SLOT(setSearchBarReplaceVisible(bool)));
    connect(m_search_ui->closeBtn, SIGNAL(clicked()),    SLOT(hideSearch()));
    connect(find_esc_s, SIGNAL(activated()),             SLOT(hideSearch()));
    connect(find_s, SIGNAL(activated()),                 SLOT(showSearch()));
    connect(replace_s, SIGNAL(activated()),              SLOT(showReplace()));
    connect(m_search_ui->nextBtn, SIGNAL(clicked()), SLOT(findNext()));
    connect(m_search_ui->prevBtn, SIGNAL(clicked()), SLOT(findPrev()));
    connect(m_search_ui->findEdit, SIGNAL(textEdited(QString)), SLOT(findNext()));
    connect(m_search_ui->replaceBtn, SIGNAL(clicked()), SLOT(replace()));
    connect(m_search_ui->replaceAllBtn, SIGNAL(clicked()), SLOT(replaceAll()));
    connect(m_search_ui->findEdit, SIGNAL(returnPressed()), SLOT(findNext()));
}
コード例 #6
0
void QsvTextOperationsWidget::initSearchWidget()
{
	m_search = new QWidget( (QWidget*) parent() );
	m_search->setObjectName("m_search");
	searchFormUi = new Ui::searchForm();
	searchFormUi->setupUi(m_search);
	searchFormUi->searchText->setFont( m_search->parentWidget()->font() );
        if (searchFormUi->frame->style()->inherits("QWindowsStyle"))
		searchFormUi->frame->setFrameStyle(QFrame::StyledPanel);
	// otherwise it inherits the default font from the editor - fixed
	m_search->setFont(QApplication::font());
	m_search->adjustSize();
	m_search->hide();

	connect(searchFormUi->searchText,SIGNAL(textChanged(QString)),this,SLOT(on_searchText_modified(QString)));
	connect(searchFormUi->nextButton,SIGNAL(clicked()),this,SLOT(searchNext()));
	connect(searchFormUi->previousButton,SIGNAL(clicked()),this,SLOT(searchPrev()));
	connect(searchFormUi->closeButton,SIGNAL(clicked()),this, SLOT(showSearch()));
}
コード例 #7
0
MainController::MainController(): m_mw(new MainWindow), m_search(m_mw)
{


    connect(m_mw, SIGNAL(s_save(QString)), this, SLOT(save(QString)));
    connect(m_mw, SIGNAL(s_load(QString)), this, SLOT(load(QString)));
    connect(m_mw, SIGNAL(s_newBase()), this, SLOT(newBase()));

    connect(m_mw, SIGNAL(s_addCategory(QString)), this, SLOT(newCategory(QString)));
    connect(m_mw, SIGNAL(s_removeCategory(QString)), this, SLOT(removeCategory(QString)));
    connect(m_mw, SIGNAL(s_seeCategory()), this, SLOT(editCategory()));
    connect(m_mw, SIGNAL(s_showCategory()), this, SLOT(showCategory()));

    connect(m_mw, SIGNAL(s_addMedia(QString)), this, SLOT(newMedia(QString)));
    connect(m_mw, SIGNAL(s_removeMedia(QString,QString)), this, SLOT(removeMedia(QString,QString)));
    connect(m_mw, SIGNAL(s_seeMedia()), this, SLOT(editMedia()));

    connect(m_mw, SIGNAL(s_showUser()), this, SLOT(setUser()));

    connect(m_mw, SIGNAL(s_search()), this, SLOT(search()));

    connect(&m_search, SIGNAL(s_find(QList<MediaSPointer>)), this, SLOT(showSearch(QList<MediaSPointer>)));

    connect(m_mw, SIGNAL(s_settings()), this, SLOT(settings()));

    m_mw->setShortcut(SettingsController::settings());

    SettingsController artemis;
    artemis.newSettings(SettingsController::settings());

    if(UserController::userCount() == 0)
        UserController().exec();
    else
        UserController::connectUser();

}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: hkahn/qt5-qttools-nacl
QT_BEGIN_NAMESPACE

MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
    : QMainWindow(parent)
    , m_bookmarkWidget(0)
    , m_filterCombo(0)
    , m_toolBarMenu(0)
    , m_cmdLine(cmdLine)
    , m_progressWidget(0)
    , m_qtDocInstaller(0)
    , m_connectedInitSignals(false)
{
    TRACE_OBJ

    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    setDockOptions(dockOptions() | AllowNestedDocks);

    QString collectionFile;
    if (usesDefaultCollection()) {
        MainWindow::collectionFileDirectory(true);
        collectionFile = MainWindow::defaultHelpCollectionFileName();
    } else {
        collectionFile = cmdLine->collectionFile();
    }
    HelpEngineWrapper &helpEngineWrapper =
        HelpEngineWrapper::instance(collectionFile);
    BookmarkManager *bookMarkManager = BookmarkManager::instance();

    if (!initHelpDB(!cmdLine->collectionFileGiven())) {
        qDebug("Fatal error: Help engine initialization failed. "
            "Error message was: %s\nAssistant will now exit.",
            qPrintable(HelpEngineWrapper::instance().error()));
        std::exit(1);
    }

    m_centralWidget = new CentralWidget(this);
    setCentralWidget(m_centralWidget);

    m_indexWindow = new IndexWindow(this);
    QDockWidget *indexDock = new QDockWidget(tr("Index"), this);
    indexDock->setObjectName(QLatin1String("IndexWindow"));
    indexDock->setWidget(m_indexWindow);
    addDockWidget(Qt::LeftDockWidgetArea, indexDock);

    m_contentWindow = new ContentWindow;
    QDockWidget *contentDock = new QDockWidget(tr("Contents"), this);
    contentDock->setObjectName(QLatin1String("ContentWindow"));
    contentDock->setWidget(m_contentWindow);
    addDockWidget(Qt::LeftDockWidgetArea, contentDock);

    m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine());
    m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font()
        : helpEngineWrapper.browserFont());
    QDockWidget *searchDock = new QDockWidget(tr("Search"), this);
    searchDock->setObjectName(QLatin1String("SearchWindow"));
    searchDock->setWidget(m_searchWindow);
    addDockWidget(Qt::LeftDockWidgetArea, searchDock);

    QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
    bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
    bookmarkDock->setWidget(m_bookmarkWidget
        = bookMarkManager->bookmarkDockWidget());
    addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);

    QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this);
    openPagesDock->setObjectName(QLatin1String("Open Pages"));
    OpenPagesManager *openPagesManager
        = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url());
    openPagesDock->setWidget(openPagesManager->openPagesWidget());
    addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);

    connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
        bookMarkManager, SLOT(addBookmark(QString, QString)));
    connect(bookMarkManager, SIGNAL(escapePressed()), this,
            SLOT(activateCurrentCentralWidgetTab()));
    connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
            SLOT(setSource(QUrl)));
    connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)),
        openPagesManager, SLOT(createPage(QUrl)));

    QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
    connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
    connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));

    QString defWindowTitle = tr("Qt Assistant");
    setWindowTitle(defWindowTitle);

    setupActions();
    statusBar()->show();
    m_centralWidget->connectTabBar();

    setupFilterToolbar();
    setupAddressToolbar();

    const QString windowTitle = helpEngineWrapper.windowTitle();
    setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
    QByteArray iconArray = helpEngineWrapper.applicationIcon();
    if (iconArray.size() > 0) {
        QPixmap pix;
        pix.loadFromData(iconArray);
        QIcon appIcon(pix);
        qApp->setWindowIcon(appIcon);
    } else {
        QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png"));
        qApp->setWindowIcon(appIcon);
    }

    QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar"));
    toolBar->setObjectName(QLatin1String("Bookmark Toolbar"));
    bookMarkManager->setBookmarksToolbar(toolBar);

    // Show the widget here, otherwise the restore geometry and state won't work
    // on x11.
    show();

    toolBar->hide();
    toolBarMenu()->addAction(toolBar->toggleViewAction());

    QByteArray ba(helpEngineWrapper.mainWindow());
    if (!ba.isEmpty())
        restoreState(ba);

    ba = helpEngineWrapper.mainWindowGeometry();
    if (!ba.isEmpty()) {
        restoreGeometry(ba);
    } else {
        tabifyDockWidget(contentDock, indexDock);
        tabifyDockWidget(indexDock, bookmarkDock);
        tabifyDockWidget(bookmarkDock, searchDock);
        contentDock->raise();
        const QRect screen = QApplication::desktop()->screenGeometry();
        resize(4*screen.width()/5, 4*screen.height()/5);
    }

    if (!helpEngineWrapper.hasFontSettings()) {
        helpEngineWrapper.setUseAppFont(false);
        helpEngineWrapper.setUseBrowserFont(false);
        helpEngineWrapper.setAppFont(qApp->font());
        helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
        helpEngineWrapper.setBrowserFont(qApp->font());
        helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
    } else {
        updateApplicationFont();
    }

    updateAboutMenuText();

    QTimer::singleShot(0, this, SLOT(insertLastPages()));
    if (m_cmdLine->enableRemoteControl())
        (void)new RemoteControl(this);

    if (m_cmdLine->contents() == CmdLineParser::Show)
        showContents();
    else if (m_cmdLine->contents() == CmdLineParser::Hide)
        hideContents();

    if (m_cmdLine->index() == CmdLineParser::Show)
        showIndex();
    else if (m_cmdLine->index() == CmdLineParser::Hide)
        hideIndex();

    if (m_cmdLine->bookmarks() == CmdLineParser::Show)
        showBookmarksDockWidget();
    else if (m_cmdLine->bookmarks() == CmdLineParser::Hide)
        hideBookmarksDockWidget();

    if (m_cmdLine->search() == CmdLineParser::Show)
        showSearch();
    else if (m_cmdLine->search() == CmdLineParser::Hide)
        hideSearch();

    if (m_cmdLine->contents() == CmdLineParser::Activate)
        showContents();
    else if (m_cmdLine->index() == CmdLineParser::Activate)
        showIndex();
    else if (m_cmdLine->bookmarks() == CmdLineParser::Activate)
        showBookmarksDockWidget();

    if (!m_cmdLine->currentFilter().isEmpty()) {
        const QString &curFilter = m_cmdLine->currentFilter();
        if (helpEngineWrapper.customFilters().contains(curFilter))
            helpEngineWrapper.setCurrentFilter(curFilter);
    }

    if (usesDefaultCollection())
        QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation()));
    else
        checkInitState();

    connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)),
            this, SLOT(documentationRemoved(QString)));
    connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)),
            this, SLOT(documentationUpdated(QString)));

    setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
    GlobalActions::instance()->updateActions();
    if (helpEngineWrapper.addressBarEnabled())
        showNewAddress();
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: darkaio/AiOqwingraph
void MainWindow::createActions() {
  printAct = new QAction(QIcon(":/images/print.png"), tr("&Print..."), this);
  //   printAct->setShortcut(QKeySequence::Print);
  printAct->setStatusTip(tr("Print the document"));
  connect(printAct, SIGNAL(triggered()), this, SLOT(printFile()));
  
  // Added by AiO to Open a new file
  openAct = new QAction(tr("&Open"), this);
  openAct->setShortcut(Qt::Key_O | Qt::CTRL);
  openAct->setStatusTip(tr("Open a new file"));
  connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
  
  saveAsAct = new QAction(tr("Save &As..."), this);
  //   saveAsAct->setShortcut(QKeySequence::SaveAs);
  saveAsAct->setStatusTip(tr("Save the document under a new name"));
  connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

  exitAct = new QAction(tr("E&xit"), this);
  exitAct->setShortcut(Qt::Key_Escape);
  exitAct->setStatusTip(tr("Exit the application"));
  connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

  normalAct = new QAction(QIcon(":/images/normalView.png"), tr("Normal view"), this);
  normalAct->setCheckable(true);
  normalAct->setChecked(true);
  normalAct->setShortcut(Qt::Key_N);
  normalAct->setStatusTip(tr("Normal view"));
  connect(normalAct, SIGNAL(triggered()), this, SLOT(normal()));

  polarAct = new QAction(QIcon(":/images/polar.png"), tr("Polar fish eye"), this);
  polarAct->setCheckable(true);
  polarAct->setShortcut(Qt::Key_P | Qt::CTRL);
  polarAct->setStatusTip(tr("Polar fish eye"));
  connect(polarAct, SIGNAL(triggered()), this, SLOT(polar()));

  polarFixedAct = new QAction(QIcon(":/images/fixedPolar.png"), tr("Fixed radius polar fish eye"), this);
  polarFixedAct->setCheckable(true);
  polarFixedAct->setShortcut(Qt::Key_P);
  polarFixedAct->setStatusTip(tr("Fixed radius polar fish eye"));
  connect(polarFixedAct, SIGNAL(triggered()), this, SLOT(polarFixed()));

  cartAct = new QAction(QIcon(":/images/cartesian.png"), tr("Cartesian fish eye"), this);
  cartAct->setCheckable(true);
  cartAct->setShortcut(Qt::Key_C | Qt::CTRL);
  cartAct->setStatusTip(tr("Cartesian fish eye"));
  connect(cartAct, SIGNAL(triggered()), this, SLOT(cart()));

  cartFixedAct = new QAction(QIcon(":/images/fixedCartesian.png"), tr("Fixed radius cartesian fish eye"), this);
  cartFixedAct->setCheckable(true);
  cartFixedAct->setShortcut(Qt::Key_C);
  cartFixedAct->setStatusTip(tr("Fixed radius cartesian fish eye"));
  connect(cartFixedAct, SIGNAL(triggered()), this, SLOT(cartFixed()));

  showLabelsAct = new QAction(QIcon(":/images/labelEdges.png"), tr("Display edge labels"), this);
  showLabelsAct->setCheckable(true);
  showLabelsAct->setStatusTip(tr("Display edge labels"));
  connect(showLabelsAct, SIGNAL(triggered()), this, SLOT(showLabels()));
  //   connect(showLabelsAct, SIGNAL(toggled(bool)), this, SLOT(toggleShowLabels(bool)));

  zoomInAct = new QAction(QIcon(":/images/zoomIn.png"), tr("Zoom in"), this);
  zoomInAct->setShortcut(Qt::Key_Plus);
  zoomInAct->setStatusTip(tr("Zoom in"));
  connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

  zoomOutAct = new QAction(QIcon(":/images/zoomOut.png"), tr("Zoom out"), this);
  zoomOutAct->setShortcut(Qt::Key_Minus);
  zoomOutAct->setStatusTip(tr("Zoom out"));
  connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

  zoomNormalAct = new QAction(QIcon(":/images/zoomNormal.png"), tr("Zoom normal"), this);
  zoomNormalAct->setShortcut(Qt::Key_0);
  zoomNormalAct->setStatusTip(tr("Zoom normal (100%)"));
  connect(zoomNormalAct, SIGNAL(triggered()), this, SLOT(zoomNormal()));

  fitAllAct = new QAction(QIcon(":/images/fitAll.png"), tr("Fit all graph"), this);
  fitAllAct->setShortcut(Qt::Key_M);
  fitAllAct->setStatusTip(tr("Fit all graph"));
  connect(fitAllAct, SIGNAL(triggered()), this, SLOT(fitAll()));

  positOriginAct = new QAction(QIcon(":/images/positOrigin.png"), tr("Position on origin"), this);
  positOriginAct->setShortcut(Qt::Key_O);
  positOriginAct->setStatusTip(tr("Position on origin"));
  connect(positOriginAct, SIGNAL(triggered()), this, SLOT(positOrigin()));

  easyPanAct = new QAction(tr("Easy graph panning"), this);
  easyPanAct->setCheckable(true);
  easyPanAct->setStatusTip(tr("Easy graph panning"));
  connect(easyPanAct, SIGNAL(triggered()), this, SLOT(easyPan()));

  helpAct = new QAction(tr("Help"), this);
  helpAct->setShortcut(Qt::Key_F1);
  helpAct->setStatusTip(tr("Display help"));
  connect(helpAct, SIGNAL(triggered()), this /*qApp*/, SLOT(help()));

  aboutAct = new QAction(tr("&About..."), this);
  aboutAct->setStatusTip(tr("Show the About box"));
  connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
  
  //Added by AiO  new action for search window
  searchAct = new QAction(tr("&Search"), this);
  searchAct->setShortcut(Qt::Key_F5);
  searchAct->setStatusTip(tr("Search F5"));
  connect(searchAct, SIGNAL(triggered()), this, SLOT(showSearch()));

}
コード例 #10
0
void QsciEditor::setupActions() {

	cutAct = new QAction( QIcon::fromTheme( "edit-cut" ), "Cu&t", this );
	cutAct->setStatusTip( "Cut the selected text" );
	cutAct->setShortcut( tr( "Ctrl+X" ) );

	copyAct = new QAction( QIcon::fromTheme( "edit-copy" ), "&Copy", this );
	copyAct->setStatusTip( "Copy the selected text" );
	copyAct->setShortcut( tr( "Ctrl+C" ) );

	pasteAct = new QAction( QIcon::fromTheme( "edit-paste" ), "&Paste", this );
	pasteAct->setStatusTip( "Paste the text on the clipboard" );
	pasteAct->setShortcut( tr( "Ctrl+V" ) );

	deleteAct = new QAction( QIcon::fromTheme( "edit-delete" ), "&Delete", this );
	deleteAct->setStatusTip( "Delete the selected Text" );
	deleteAct->setShortcut( tr( "Delete" ) );

	selectAct = new QAction( QIcon::fromTheme( "edit-select-all" ), "Select &All", this );
	selectAct->setStatusTip( "Select all the text" );
	selectAct->setShortcut( tr( "Ctrl+A" ) );

	deselectAct = new QAction( QIcon(), "Deselect &All", this );
	deselectAct->setStatusTip( "Deselect all the text" );
	deselectAct->setShortcut( tr( "Ctrl+Shift+A" ) );

	undoAct = new QAction( QIcon::fromTheme( "edit-undo" ), "&Undo", this );
	undoAct->setStatusTip( "Undo the last change" );
	undoAct->setShortcut( tr( "Ctrl+Z" ) );

	redoAct = new QAction( QIcon::fromTheme( "edit-redo" ), "&Redo", this );
	redoAct->setStatusTip( "Redo the undone change" );
	redoAct->setShortcut( tr( "Ctrl+Y" ) );

	searchAct = new QAction( QIcon::fromTheme( "edit-find" ), "&Search", this );
	searchAct->setStatusTip( "Search the document" );
	searchAct->setShortcut( tr( "Ctrl+F" ) );

	replaceAct = new QAction( QIcon::fromTheme( "edit-find-replace" ), "&Replace", this );
	replaceAct->setStatusTip( "Replace text in the document" );
	replaceAct->setShortcut( tr( "Ctrl+R" ) );

	changeFontAct = new QAction( QIcon::fromTheme( "preferences-desktop-font" ), "Change &Font", this );
	changeFontAct->setStatusTip( "Change the font of the document" );
	changeFontAct->setShortcut( tr( "Ctrl+Shift+F" ) );

	toggleCaseAct = new QAction( "T&oggle Case of Selection", this );
	toggleCaseAct->setStatusTip( "Toggle the case of the selected text" );
	toggleCaseAct->setShortcut( tr( "Ctrl+Alt+U" ) );

	connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( showCustomMenu( const QPoint& ) ) );

	connect( cutAct, SIGNAL( triggered() ), this, SLOT( cutAction() ) );
	connect( copyAct, SIGNAL( triggered() ), this, SLOT( copyAction() ) );
	connect( pasteAct, SIGNAL( triggered() ), this, SLOT( pasteAction() ) );
	connect( deleteAct, SIGNAL( triggered() ), this, SLOT( deleteAction() ) );

	connect( undoAct, SIGNAL( triggered() ), this, SLOT( undoAction() ) );
	connect( redoAct, SIGNAL( triggered() ), this, SLOT( redoAction() ) );

	connect( selectAct, SIGNAL( triggered() ), this, SLOT( selectAction() ) );
	connect( deselectAct, SIGNAL( triggered() ), this, SLOT( deselectAction() ) );

	connect( changeFontAct, SIGNAL( triggered() ), this, SLOT( changeFont() ) );
	connect( toggleCaseAct, SIGNAL( triggered() ), this, SLOT( toggleCase() ) );

	connect( searchAct, SIGNAL( triggered() ), this, SLOT( showSearch() ) );
	connect( this, SIGNAL( linesChanged() ), this, SLOT( resizeMargins() ) );

	addAction( cutAct );
	addAction( copyAct );
	addAction( pasteAct );
	addAction( deleteAct );
	addAction( selectAct );
	addAction( deselectAct );
	addAction( undoAct );
	addAction( redoAct );
	addAction( searchAct );
	addAction( replaceAct );
	addAction( changeFontAct );
	addAction( toggleCaseAct );

	/* Change keyBindings */
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_DOWN + ( SCMOD_CTRL << 16 ), SCI_PARADOWN );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_UP + ( SCMOD_CTRL << 16 ), SCI_PARAUP );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_DOWN + ( SCMOD_ALT << 16 ), SCI_LINESCROLLDOWN );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_UP + ( SCMOD_ALT << 16 ), SCI_LINESCROLLUP );

	/* Remove Ctrl+D as duplicate line */
	SendScintilla( SCI_CLEARCMDKEY, 68 + ( SCMOD_CTRL << 16 ) );
};
コード例 #11
0
bool	 QsvTextOperationsWidget::eventFilter(QObject *obj, QEvent *event)
{
	if (obj != parent())
		return false;
	if (event->type() != QEvent::KeyPress)
		return false;

	QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
	switch (keyEvent->key()){
		case Qt::Key_Escape:
			if (m_search && m_search->isVisible()){
				showSearch();
				return true;
			} else if (m_replace && m_replace->isVisible()){
				showReplace();
				return true;
			}/* else if (m_gotoLine && m_gotoLine->isVisible()) {
				showGotoLine();
				return true;
			}*/
			break;
			
		case Qt::Key_Enter:
		case Qt::Key_Return:
			if (m_search && m_search->isVisible()){
				if (keyEvent->modifiers().testFlag(Qt::ControlModifier) ||
				    keyEvent->modifiers().testFlag(Qt::AltModifier) ||
				    keyEvent->modifiers().testFlag(Qt::ShiftModifier) )
					searchPrev();
				else
					searchNext();
				return true;
			} else if (m_replace && m_replace->isVisible()){
				if (keyEvent->modifiers().testFlag(Qt::ControlModifier) ||
				    keyEvent->modifiers().testFlag(Qt::AltModifier) ||
				    keyEvent->modifiers().testFlag(Qt::ShiftModifier) )
					on_replaceAll_clicked();
				else
					on_replaceOldText_returnPressed();
				return true;
			}
			
			// TODO replace, goto line
			break;

		case Qt::Key_Tab:
		case Qt::Key_Backtab:
			if (m_replace && m_replace->isVisible()){
				/*
				// TODO - no cycle yet.
				if (Qt::Key_Tab == keyEvent->key())
					m_replace->focusWidget()->nextInFocusChain()->setFocus();
				else
					m_replace->focusWidget()->previousInFocusChain()->setFocus();
				*/
				// Instead - cycle between those two input lines. IMHO good enough
				if (replaceFormUi->replaceText->hasFocus()){
					replaceFormUi->findText->setFocus();
					replaceFormUi->findText->selectAll();
				}
				else{
					replaceFormUi->replaceText->setFocus();
					replaceFormUi->replaceText->selectAll();
				}
				return true;
			}
			break;
	}

	return false;
}
コード例 #12
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch){
            if (m_search)
                delete m_search;
            m_search = new JabberWizard(this, I18N_NOOP("%1 Search"), "find", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            m_search_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister){
            if (m_reg)
                delete m_reg;
            m_reg = new JabberWizard(this, I18N_NOOP("%1 Register"), "reg", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            m_reg_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure){
            if (m_config)
                delete m_config;
            m_config = new JabberWizard(this, I18N_NOOP("%1 Configure"), "configure", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            m_config_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl){
            if (!m_id1.empty() || !m_id2.empty()){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo){
            if (m_category.isEmpty() && m_type.isEmpty() && m_name.isEmpty() && m_features.isEmpty())
                return e->param();
            if (m_info == NULL)
                m_info = new DiscoInfo(this);
            m_info->reset();
            raiseWindow(m_info);
            return e->param();
        }
    }
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventDiscoItem){
        JabberDiscoItem *item = (JabberDiscoItem*)(e->param());
        if (m_id1 == item->id){
            if (item->jid.empty()){
                m_id1 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (err.isEmpty() || m_id2.empty())
                    stop(err);
                return e->param();
            }
            QListViewItem *i = new QListViewItem(m_list);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_id2 == item->id){
            if (item->jid.empty()){
                m_id2 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (m_id1.empty())
                    stop(err);
                return e->param();
            }
            if (item->jid == "feature"){
                if (!m_features.isEmpty())
                    m_features += "\n";
                m_features += QString::fromUtf8(item->name.c_str());
            }else{
                m_category = QString::fromUtf8(item->jid.c_str());
                m_type	   = QString::fromUtf8(item->node.c_str());
                m_name	   = QString::fromUtf8(item->name.c_str());
            }
            return e->param();
        }
    }
    return NULL;
}
コード例 #13
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->menu_id != MenuBrowser)
            return NULL;
        cmd->flags &= ~COMMAND_CHECKED;
        switch (cmd->id){
        case CmdOneLevel:
            if (!m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdAllLevels:
            if (m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeDisco:
            if (m_client->getBrowseType() & BROWSE_DISCO)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeBrowse:
            if (m_client->getBrowseType() & BROWSE_BROWSE)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeAgents:
            if (m_client->getBrowseType() & BROWSE_AGENTS)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        QListViewItem *item = m_list->currentItem();
        if (cmd->menu_id == MenuBrowser){
            cmd->flags &= ~COMMAND_CHECKED;
            unsigned mode = m_client->getBrowseType();
            switch (cmd->id){
            case CmdOneLevel:
                m_client->setAllLevels(false);
				changeMode();
                return e->param();
            case CmdAllLevels:
                m_client->setAllLevels(true);
				changeMode();
                return e->param();
            case CmdModeDisco:
				mode ^= BROWSE_DISCO;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeBrowse:
				mode ^= BROWSE_BROWSE;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeAgents:
				mode ^= BROWSE_AGENTS;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            }
            return NULL;
        }
        if (item){
            if (cmd->id == CmdBrowseSearch){
                if (m_search)
                    delete m_search;
                m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                return e->param();
            }
            if (cmd->id == CmdRegister){
                if (m_reg)
                    delete m_reg;
                m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                return e->param();
            }
            if (cmd->id == CmdBrowseConfigure){
                if (m_config)
                    delete m_config;
                m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                return e->param();
            }
            if (cmd->id == CmdBrowseInfo){
                if (m_info == NULL)
                    m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY));
                m_info->reset();
                raiseWindow(m_info);
                return e->param();
            }
        }
        if (cmd->id == CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdUrl){
            if (m_bInProcess){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
    }
    if (e->type() == EventDiscoItem){
        if (!m_bInProcess)
            return NULL;
        DiscoItem *item = (DiscoItem*)(e->param());
        QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_ITEMS, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->firstChild() == NULL){
                it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
            }
            QListViewItem *i;
            for (i = it->firstChild(); i; i = i->nextSibling()){
                if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                        (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                    return e->param();
            }
            i = new QListViewItem(it);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            int mode = 0;
            if (m_client->getBrowseType() & BROWSE_DISCO){
                i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str());
                mode |= BROWSE_INFO;
            }
            i->setText(COL_MODE, QString::number(mode));
			if (m_client->getAllLevels())
				loadItem(i);
            return e->param();
        }
        it = findItem(COL_ID_DISCO_INFO, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_INFO, "");
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if ((m_client->getAllLevels()) || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            if (it == m_list->currentItem())
                currentChanged(it);
            return e->param();
        }
        it = findItem(COL_ID_BROWSE, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_BROWSE, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                    QString err;
                    if (!item->name.empty()){
                        err = QString::fromUtf8(item->name.c_str());
                    }else if (!item->node.empty()){
                        err = i18n("Error %1") .arg(atol(item->node.c_str()));
                    }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
				adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){
                QListViewItem *i;
                for (i = it->firstChild(); i; i = i->nextSibling()){
                    if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                            (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                        break;
                }
                if (i){
                    it = i;
                }else{
					if (it->firstChild() == NULL){
						it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
					}
                    it = new QListViewItem(it);
                    it->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
                    if (m_client->getAllLevels())
						loadItem(it);
                }
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if (m_client->getAllLevels() || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            return e->param();
        }
    }
    return NULL;
}
コード例 #14
0
void EditorWidgetQSci::showReplace()
{
    setSearchBarReplaceVisible(true);
    showSearch();
}
コード例 #15
0
ファイル: mainwindow.cpp プロジェクト: KasaiDot/Shinjiru
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
  ui->setupUi(this);

  QFile styleFile(":/style.css");
  styleFile.open(QFile::ReadOnly);
  QString styleSheet = QLatin1String(styleFile.readAll());
  qApp->setStyleSheet(styleSheet);

  QPixmap window_icon;
  QFile iconFile(":/icon.png");
  iconFile.open(QFile::ReadOnly);
  QByteArray icon_data = iconFile.readAll();
  window_icon.loadFromData(icon_data);
  qApp->setWindowIcon(QIcon(window_icon));

  awesome = new QtAwesome(qApp);
  settings = new Settings(this);
  window_watcher = new WindowWatcher(this);
  anitomy = new AnitomyWrapper();
  event_timer = new QTimer(this);
  watch_timer = new QTimer(this);
  uptime_timer = new QElapsedTimer;
  progress_bar = new QProgressBar(ui->statusBar);
  over = new Overlay(this);
  torrent_refresh_time = 0;
  user_refresh_time =
      settings->getValue(Settings::UserRefreshTime, D_USER_REFRESH_TIME)
          .toInt();
  download_rule = 0;
  download_count = 0;
  hasUser = false;

  uptime_timer->start();
  watch_timer->setSingleShot(true);

  awesome->initFontAwesome();

  bool check_for_updates =
      settings->getValue(Settings::CheckUpdates, D_CHECK_FOR_UPDATES).toBool();

  if (check_for_updates) {
    connect(FvUpdater::sharedUpdater(), &FvUpdater::restartRequested,
            [&]() {  // NOLINT
              QString app = QApplication::applicationFilePath();
              QStringList arguments = QApplication::arguments();
              QString wd = QDir::currentPath();
              QProcess::startDetached(app, arguments, wd);
              elegantClose(true);
            });

    FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
  }

  QFont font = ui->listTabs->tabBar()->font();
  font.setCapitalization(QFont::Capitalize);
  ui->listTabs->tabBar()->setFont(font);

  int currentYear = QDate::currentDate().year();
  int lowerYear = currentYear - 10;

  while (currentYear > lowerYear) {
    ui->comboYear->addItem(QString::number(currentYear));
    currentYear--;
  }

  QWidget *container = new QWidget(ui->scrollArea);
  layout = new FlowLayout(container);
  ui->scrollArea->setWidget(container);
  container->setLayout(layout);

  QWidget *container2 = new QWidget(ui->scrollArea_2);
  layout2 = new FlowLayout(container2);
  layout2->disableSort();
  ui->scrollArea_2->setWidget(container2);
  container2->setLayout(layout2);

  QVariantMap black;
  black.insert("color", QColor(0, 0, 0));
  black.insert("color-active", QColor(0, 0, 0));
  black.insert("color-disabled", QColor(0, 0, 0));
  black.insert("color-selected", QColor(0, 0, 0));

  ui->airingButton->setIcon(awesome->icon(fa::clocko, black));
  ui->torrentsButton->setIcon(awesome->icon(fa::rss, black));
  ui->animeButton->setIcon(awesome->icon(fa::bars, black));
  ui->seasonsButton->setIcon(awesome->icon(fa::th, black));
  ui->statisticsButton->setIcon(awesome->icon(fa::piechart, black));

  ui->tabWidget->tabBar()->hide();
  ui->tabWidget->setCurrentIndex(UserTabs::tAnime);
  ui->listTabs->setCurrentIndex(0);

  ui->statusBar->addWidget(progress_bar);
  ui->statusBar->layout()->setContentsMargins(1, 0, 0, 0);
  progress_bar->setRange(0, 100);
  progress_bar->setValue(5);
  progress_bar->setFormat("Authorizing");

  QSettings s;
  restoreGeometry(s.value("mainWindowGeometry").toByteArray());
  restoreState(s.value("mainWindowState").toByteArray());

  connect(&user_future_watcher, SIGNAL(finished()), SLOT(userLoaded()));
  connect(&user_list_future_watcher, SIGNAL(finished()),
          SLOT(userListLoaded()));

  connect(ui->animeButton, SIGNAL(clicked()), SLOT(showAnimeTab()));
  connect(ui->airingButton, SIGNAL(clicked()), SLOT(showAiringTab()));
  connect(ui->torrentsButton, SIGNAL(clicked()), SLOT(showTorrentsTab()));
  connect(ui->seasonsButton, SIGNAL(clicked()), SLOT(showBrowseTab()));
  connect(ui->actionSettings, SIGNAL(triggered()), SLOT(showSettings()));
  connect(ui->statisticsButton, SIGNAL(clicked()), SLOT(showStatisticsTab()));

  connect(ui->actionExit, &QAction::triggered, [&, this]() {  // NOLINT
    this->elegantClose();
  });

  connect(ui->actionAbout, &QAction::triggered, [&, this]() {  // NOLINT
    About *about = new About(this);
    about->show();
  });

  connect(ui->actionHelp, &QAction::triggered, [&, this]() {  // NOLINT
    QDesktopServices::openUrl(QUrl("http://app.shinjiru.me/support.php"));
  });

  connect(ui->actionRL, &QAction::triggered, [&, this]() {  // NOLINT
    loadUser();
  });

  connect(ui->actionAS, &QAction::triggered, [&]() {  // NOLINT
    SearchPanel *sp = new SearchPanel(this);
    sp->show();
  });

  connect(ui->actionARR, &QAction::triggered, [&, this]() {  // NOLINT
    SettingsDialog *s = new SettingsDialog(this);
    s->showSmartTitles();

    connect(s, &QDialog::accepted, [&, this]() {  // NOLINT
      Settings set;

      toggleAnimeRecognition(
          set.getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
              .toBool());

      torrents_enabled =
          set.getValue(Settings::TorrentsEnabled, D_TORRENTS_ENABLED).toBool();

      reloadSmartTitles();
      reloadRules();
    });
  });

  connect(qApp, SIGNAL(aboutToQuit()), SLOT(elegantClose()));

  connect(ui->actionVAL, SIGNAL(triggered()), SLOT(viewAnimeList()));
  connect(ui->actionVD, SIGNAL(triggered()), SLOT(viewDashboard()));
  connect(ui->actionVP, SIGNAL(triggered()), SLOT(viewProfile()));
  connect(ui->actionEAR, SIGNAL(triggered(bool)),
          SLOT(toggleAnimeRecognition(bool)));
  connect(ui->actionExport, SIGNAL(triggered()), SLOT(exportListJSON()));
  connect(ui->actionUpdate, SIGNAL(triggered()), FvUpdater::sharedUpdater(),
          SLOT(CheckForUpdatesNotSilent()));

  connect(window_watcher, SIGNAL(title_found(QString)), SLOT(watch(QString)));
  connect(watch_timer, SIGNAL(timeout()), SLOT(updateEpisode()));
  connect(event_timer, SIGNAL(timeout()), SLOT(eventTick()));

  connect(ui->torrentTable, SIGNAL(customContextMenuRequested(QPoint)),
          SLOT(torrentContextMenu(QPoint)));
  connect(ui->torrentFilter, SIGNAL(textChanged(QString)),
          SLOT(filterTorrents(QString)));
  connect(ui->chkHideUnknown, SIGNAL(toggled(bool)),
          SLOT(filterTorrents(bool)));
  connect(ui->refreshButton, SIGNAL(clicked()), SLOT(refreshTorrentListing()));

  connect(ui->actionEAR, SIGNAL(toggled(bool)), SLOT(applyEAR()));

  connect(ui->tabWidget, &QTabWidget::currentChanged, [&, this](  // NOLINT
                                                          int tab) {
    if (tab != 0) {
      this->over->removeDrawing("blank_table");
      this->over->removeDrawing("no anime");
      ui->listTabs->show();
      ui->listFilterLineEdit->show();
    } else {
      this->filterList(3);

      if (hasUser && (User::sharedUser()->getAnimeList().count() == 0)) {
        this->addNoAnimePrompt();
      }
    }
  });

  ui->actionEAR->setChecked(
      settings->getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
          .toBool());

  this->toggleAnimeRecognition(ui->actionEAR->isChecked());

  QString genrelist =
      "Action, Adult, Adventure, Cars, Comedy, Dementia, Demons, Doujinshi, "
      "Drama, Ecchi, Fantasy, Game, Gender Bender, Harem, Hentai, Historical, "
      "Horror, Josei, Kids, Magic, Martial Arts, Mature, Mecha, Military, "
      "Motion Comic, Music, Mystery, Mythological , Parody, Police, "
      "Psychological, Romance, Samurai, School, Sci-Fi, Seinen, Shoujo, Shoujo "
      "Ai, Shounen, Shounen Ai, Slice of Life, Space, Sports, Super Power, "
      "Supernatural, Thriller, Tragedy, Vampire, Yaoi, Yuri";
  QStringList genres = genrelist.split(", ");

  for (QString genre : genres) {
    QCheckBox *chk = new QCheckBox();

    chk->setText(genre);
    chk->setTristate(true);

    ui->genreList->addWidget(chk);
  }

  connect(ui->listFilterLineEdit, SIGNAL(textChanged(QString)),
          SLOT(filterList(QString)));
  connect(ui->listFilterLineEdit, SIGNAL(returnPressed()), SLOT(showSearch()));
  connect(ui->listTabs, SIGNAL(currentChanged(int)), SLOT(filterList(int)));

  connect(ui->browseButton, SIGNAL(clicked()), SLOT(loadBrowserData()));

  this->show();
  createActions();
  initTray();
  trayIcon->show();

  int result = API::sharedAPI()->verifyAPI();

  if (result == AniListAPI::OK) {
    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_granted,
            [&, this]() {  // NOLINT
              progress_bar->setValue(10);
              progress_bar->setFormat("Access granted");
              loadUser();

              event_timer->start(1000);
            });

    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_denied,
            [&, this](QString error) {  // NOLINT
              qCritical() << error;

              if (isVisible()) {
                QMessageBox::critical(this, "Shinjiru", tr("Error: ") + error);
              }
            });
  } else if (result == AniListAPI::NO_CONNECTION) {
    qDebug() << "Starting Shinjiru in offline mode";
    hasUser = User::sharedUser()->loadLocal();
  }

  reloadRules();
}
コード例 #16
0
ファイル: tabwidget.cpp プロジェクト: bochi/kueue
TabWidget::TabWidget( QWidget* parent )
{
    qDebug() << "[TABWIDGET] Constructing";

    mGrabbedWidget = 0;
    mTabs = 0;

    // set the tab position

    setTabsPosition();
    mStatusBar = &mStatusBar->getInstance();

    // create the tabbar

    mBar = new TabBar;
    setTabBar( mBar );

    // connect the mouse clicks

    connect( mBar, SIGNAL( tabRightClicked( int, QPoint ) ),
             this, SLOT( tabRightClicked( int, QPoint ) ) );

    connect( mBar, SIGNAL( tabMiddleClicked( int, QPoint ) ),
             this, SLOT( tabMiddleClicked( int, QPoint ) ) );

    TabButton* newTabButton = new TabButton( this );
    TabButton* mMenuButton = new TabButton( this );

    connect( newTabButton, SIGNAL( clicked() ),
             this, SLOT( addUnityBrowser()) );

    connect( newTabButton, SIGNAL( middleClicked() ),
             this, SLOT( addUnityBrowserWithSR() ) );

    connect( mMenuButton, SIGNAL( clicked() ),
             mMenuButton, SLOT( showMenu()) );

    mMenuButton->setMenu( kueueMainMenu() );

    newTabButton->setIcon( QIcon( ":icons/menus/newtab.png" ) );
    mMenuButton->setIcon( QIcon(":/icons/kueue.png") );

    if ( Settings::unityEnabled() )
    {
        setCornerWidget( newTabButton, Qt::TopRightCorner );
    }

    setCornerWidget( mMenuButton, Qt::TopLeftCorner );

    // create the main browser tabs...

    mQueueBrowser = new QueueBrowser( this );

    mSubownerBrowser = new SubownerBrowser( this );

    mPersonalTab = new BrowserWithSearch( mQueueBrowser, this );

    mSubownerTab = new BrowserWithSearch( mSubownerBrowser, this );

    connect( mQueueBrowser, SIGNAL( setMenus() ),
             this, SLOT( setMenus() ) );

    connect( mSubownerBrowser, SIGNAL( setMenus() ),
             this, SLOT( setMenus() ) );

    connect( mQueueBrowser, SIGNAL( expandAll() ),
             this, SLOT( expandAllTables() ) );

    connect( mQueueBrowser, SIGNAL( closeAll() ),
             this, SLOT( closeAllTables() ) );

    mQmonBrowser = new QMonBrowser( this );
    mMonitorTab = new BrowserWithSearch( mQmonBrowser, this );

    mStatsBrowser = new StatsBrowser( this );
    mStatsTab = new BrowserWithSearch( mStatsBrowser, this );

    if ( Settings::unityEnabled() )
    {
        addUnityBrowser();
        rebuildMaps();
    }

    mSubVisible = true;

    // ...and add them to the tabbar

    insertTab( 0, mPersonalTab, QIcon( ":icons/conf/targets.png" ), "Personal queue" );
    insertTab( 1, mSubownerTab, QIcon( ":icons/conf/targets.png" ), "Subowned SRs" );
    insertTab( 2, mMonitorTab, QIcon( ":/icons/conf/monitor.png" ), "Queue monitor" );
    insertTab( 3, mStatsTab, QIcon( ":/icons/conf/stats.png" ), "Statistics" );

    QShortcut* search = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_F ), this );

    connect( search, SIGNAL( activated() ),
             this, SLOT( showSearch() ) );

    refreshTabs();
}