/* * Copies the full path of the selected item in pkgFileListTreeView to clipboard */ void MainWindow::copyFullPathToClipboard() { QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList"); if (tb && tb->hasFocus()) { QString path = utils::showFullPathOfItem(tb->currentIndex()); QClipboard *clip = qApp->clipboard(); clip->setText(path); } }
/* * This Event method is called whenever the user presses a key */ void MainWindow::keyPressEvent(QKeyEvent* ke) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { if (ui->tvPackages->hasFocus()) { execKeyActionOnPackage(ectn_INSTALL); } //We are searching for AUR foreign packages... else if (isAURGroupSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL) { if (UnixCommand::getLinuxDistro() == ectn_KAOS) return; ui->twGroups->setEnabled(false); QFuture<QList<PackageListData> *> f; disconnect(&g_fwAUR, SIGNAL(finished()), this, SLOT(preBuildAURPackageList())); m_cic = new CPUIntensiveComputing(); f = QtConcurrent::run(searchAURPackages, m_leFilterPackage->text()); g_fwAUR.setFuture(f); connect(&g_fwAUR, SIGNAL(finished()), this, SLOT(preBuildAURPackageList())); } //We are searching for packages that own some file typed by user... else if (isSearchByFileSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL) { ui->twGroups->setEnabled(false); QFuture<QString> f; disconnect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile())); m_cic = new CPUIntensiveComputing(); f = QtConcurrent::run(searchPacmanPackagesByFile, m_leFilterPackage->text()); g_fwPackageOwnsFile.setFuture(f); connect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile())); } //We are probably inside 'Files' tab... else { QTreeView *tvPkgFileList = ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild<QTreeView*>("tvPkgFileList"); if(tvPkgFileList) { if(tvPkgFileList->hasFocus()) { openFile(); } } } } else if(ke->key() == Qt::Key_Escape) { if(m_leFilterPackage->hasFocus()) { m_leFilterPackage->clear(); } } else if(ke->key() == Qt::Key_Delete) { onPressDelete(); } else if(ke->key() == Qt::Key_1 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_INFORMATION); } else if(ke->key() == Qt::Key_2 && ke->modifiers() == Qt::AltModifier) { ui->twProperties->setCurrentIndex(ctn_TABINDEX_FILES); refreshTabFiles(false, true); } else if(ke->key() == Qt::Key_3 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_TRANSACTION); } else if(ke->key() == Qt::Key_4 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_OUTPUT); } else if(ke->key() == Qt::Key_5 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS); } else if(ke->key() == Qt::Key_6 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_HELPUSAGE); } else if(ke->key() == Qt::Key_F2) { if (isPackageTreeViewVisible()) { if (!ui->tvPackages->hasFocus()) ui->tvPackages->setFocus(); } else { maximizePropertiesTabWidget(false); if (!ui->tvPackages->hasFocus()) ui->tvPackages->setFocus(); } } else if(ke->key() == Qt::Key_F4) { openTerminal(); } else if(ke->key() == Qt::Key_F6) { openDirectory(); } else if (ke->key() == Qt::Key_F10) { maximizePackagesTreeView(false); } else if (ke->key() == Qt::Key_F12) { maximizePropertiesTabWidget(false); } else if(ke->key() == Qt::Key_C && ke->modifiers() == Qt::ControlModifier) { copyFullPathToClipboard(); } else if(ke->key() == Qt::Key_L && ke->modifiers() == Qt::ControlModifier) { m_leFilterPackage->setFocus(); m_leFilterPackage->selectAll(); } else if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier) { if (m_commandExecuting != ectn_NONE) return; if (isPropertiesTabWidgetVisible() && (ui->twProperties->currentIndex() == ctn_TABINDEX_INFORMATION || ui->twProperties->currentIndex() == ctn_TABINDEX_OUTPUT || ui->twProperties->currentIndex() == ctn_TABINDEX_NEWS || ui->twProperties->currentIndex() == ctn_TABINDEX_HELPUSAGE)) { QTextBrowser *tb = ui->twProperties->currentWidget()->findChild<QTextBrowser*>("textBrowser"); SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar"); if (tb && tb->toPlainText().size() > 0 && searchBar) { if (searchBar) searchBar->show(); } } else if (isPropertiesTabWidgetVisible() && ui->twProperties->currentIndex() == ctn_TABINDEX_FILES) { QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList"); SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar"); if (tb && tb->model()->rowCount() > 0 && searchBar) { if (searchBar) searchBar->show(); } } } else if(ke->key() == Qt::Key_D && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { //The user wants to know which packages have no description! showPackagesWithNoDescription(); } else if(ke->key() == Qt::Key_G && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { //The user wants to go to "Display All groups" if (!isAllGroupsSelected()) { ui->twGroups->setCurrentItem(m_AllGroupsItem); } } else if(ke->key() == Qt::Key_Y && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier) && m_hasAURTool) { if (m_commandExecuting != ectn_NONE) return; //The user wants to use "AUR tool" to search for pkgs m_actionSwitchToAURTool->trigger(); if (m_actionSwitchToAURTool->isChecked() && UnixCommand::getLinuxDistro() != ectn_KAOS) { m_leFilterPackage->setFocus(); } else { ui->tvPackages->setFocus(); } } else if(ke->key() == Qt::Key_C && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { if (m_commandExecuting == ectn_NONE) { doCleanCache(); //If we are not executing any command, let's clean the cache } } else if(ke->key() == Qt::Key_R && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { if (m_commandExecuting == ectn_NONE) { doRemovePacmanLockFile(); //If we are not executing any command, let's remove Pacman's lock file } } else if(ke->key() == Qt::Key_S && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { gistSysInfo(); } #if QT_VERSION >= 0x050300 else if(ke->key() == Qt::Key_T && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier) && m_initializationCompleted) { if (m_commandExecuting != ectn_NONE) return; QStringList terminals = Terminal::getListOfAvailableTerminals(); if (terminals.count() > 2) { int index = terminals.indexOf(SettingsManager::getTerminal()); int newIndex = selectTerminal(index); if (index != newIndex) { SettingsManager::setTerminal(terminals.at(newIndex)); } } } #endif else ke->ignore(); }
/* * This Event method is called whenever the user presses a key */ void MainWindow::keyPressEvent(QKeyEvent* ke) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { //We are searching for AUR foreign packages... if (isRemoteSearchSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL) { if (m_leFilterPackage->text().size() < 2) { QMessageBox::information(this, StrConstants::getWarning(), StrConstants::getSearchStringIsShort(), QMessageBox::Ok); return; } //ui->twGroups->setEnabled(false); QFuture<QList<PackageListData> *> f; disconnect(&g_fwRemote, SIGNAL(finished()), this, SLOT(preBuildRemotePackageList())); m_cic = new CPUIntensiveComputing(); f = QtConcurrent::run(searchRemotePackages, m_leFilterPackage->text()); g_fwRemote.setFuture(f); connect(&g_fwRemote, SIGNAL(finished()), this, SLOT(preBuildRemotePackageList())); } //We are searching for packages that own some file typed by user... else if (isSearchByFileSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL) { //ui->twGroups->setEnabled(false); QFuture<QString> f; disconnect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile())); m_cic = new CPUIntensiveComputing(); f = QtConcurrent::run(searchPacmanPackagesByFile, m_leFilterPackage->text()); g_fwPackageOwnsFile.setFuture(f); connect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile())); } //We are probably inside 'Files' tab... else { QTreeView *tvPkgFileList = ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild<QTreeView*>("tvPkgFileList"); if(tvPkgFileList) { if(tvPkgFileList->hasFocus()) { openFile(); } } } } else if(ke->key() == Qt::Key_Escape) { if(m_leFilterPackage->hasFocus()) { m_leFilterPackage->clear(); } } else if(ke->key() == Qt::Key_Delete) { onPressDelete(); } else if(ke->key() == Qt::Key_1 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_INFORMATION); } else if(ke->key() == Qt::Key_2 && ke->modifiers() == Qt::AltModifier) { ui->twProperties->setCurrentIndex(ctn_TABINDEX_FILES); refreshTabFiles(false, true); } else if(ke->key() == Qt::Key_3 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_TRANSACTION); } else if(ke->key() == Qt::Key_4 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_OUTPUT); } else if(ke->key() == Qt::Key_5 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS); } else if(ke->key() == Qt::Key_6 && ke->modifiers() == Qt::AltModifier) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_HELPUSAGE); } else if(ke->key() == Qt::Key_F4) { openTerminal(); } /*else if(ke->key() == Qt::Key_F5) { metaBuildPackageList(); }*/ else if(ke->key() == Qt::Key_F6) { openDirectory(); } else if (ke->key() == Qt::Key_F10) { maximizePackagesTreeView(false); } else if (ke->key() == Qt::Key_F12) { maximizePropertiesTabWidget(false); } else if(ke->key() == Qt::Key_C && ke->modifiers() == Qt::ControlModifier) { copyFullPathToClipboard(); } else if(ke->key() == Qt::Key_L && ke->modifiers() == Qt::ControlModifier) { m_leFilterPackage->setFocus(); m_leFilterPackage->selectAll(); } else if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier) { if (m_commandExecuting != ectn_NONE) return; if (isPropertiesTabWidgetVisible() && (ui->twProperties->currentIndex() == ctn_TABINDEX_INFORMATION || ui->twProperties->currentIndex() == ctn_TABINDEX_OUTPUT || ui->twProperties->currentIndex() == ctn_TABINDEX_NEWS || ui->twProperties->currentIndex() == ctn_TABINDEX_HELPUSAGE)) { QTextBrowser *tb = ui->twProperties->currentWidget()->findChild<QTextBrowser*>("textBrowser"); SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar"); if (tb && tb->toPlainText().size() > 0 && searchBar) { if (searchBar) searchBar->show(); } } else if (isPropertiesTabWidgetVisible() && ui->twProperties->currentIndex() == ctn_TABINDEX_FILES) { QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList"); SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar"); if (tb && tb->model()->rowCount() > 0 && searchBar) { if (searchBar) searchBar->show(); } } } else if(ke->key() == Qt::Key_D && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { //The user wants to know which packages have no description! showPackagesWithNoDescription(); } else if(ke->key() == Qt::Key_G && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { //The user wants to go to "Display All groups" if (!isAllCategoriesSelected()) { ui->twGroups->setCurrentItem(m_AllGroupsItem); } } else if(ke->key() == Qt::Key_C && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { if (m_commandExecuting == ectn_NONE) { doCleanCache(); //If we are not executing any command, let's clean the cache } } else if(ke->key() == Qt::Key_R && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { if (m_commandExecuting == ectn_NONE) { doRemovePacmanLockFile(); //If we are not executing any command, let's remove Pacman's lock file } } else if(ke->key() == Qt::Key_T && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier) && m_initializationCompleted) { if (m_commandExecuting != ectn_NONE) return; QStringList terminals = Terminal::getListOfAvailableTerminals(); if (terminals.count() > 2) { int index = terminals.indexOf(SettingsManager::getTerminal()); int newIndex = selectTerminal(index); if (index != newIndex) { SettingsManager::setTerminal(terminals.at(newIndex)); } } } /*else if(ke->key() == Qt::Key_Z && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) { parseXBPSProcessOutput("Updating configuration file `/etc/skel/.bashrc"); }*/ else ke->ignore(); }