//! [0] Window::Window(QWidget *parent) : QWidget(parent) { browseButton = createButton(tr("&Browse..."), SLOT(browse())); findButton = createButton(tr("&Find"), SLOT(find())); fileComboBox = createComboBox(tr("*")); textComboBox = createComboBox(); directoryComboBox = createComboBox(QDir::currentPath()); fileLabel = new QLabel(tr("Named:")); textLabel = new QLabel(tr("Containing text:")); directoryLabel = new QLabel(tr("In directory:")); filesFoundLabel = new QLabel; createFilesTable(); //! [0] //! [1] QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(fileLabel, 0, 0); mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); mainLayout->addWidget(textLabel, 1, 0); mainLayout->addWidget(textComboBox, 1, 1, 1, 2); mainLayout->addWidget(directoryLabel, 2, 0); mainLayout->addWidget(directoryComboBox, 2, 1); mainLayout->addWidget(browseButton, 2, 2); mainLayout->addWidget(filesTable, 3, 0, 1, 3); mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2); mainLayout->addWidget(findButton, 4, 2); setLayout(mainLayout); setWindowTitle(tr("Find Files")); resize(700, 300); }
QMathMLFileViewer::QMathMLFileViewer( QWidget *parent ) : QDockWidget( tr("MathML Documents Explorer"), parent ) { m_iconSize = QSize(16, 16); m_isRecursiveSearch = true; m_currentDir.setPath( QDir::currentPath() ); directoryComboBox = createComboBox( m_currentDir.absolutePath() ); directoryComboBox->setMinimumWidth(150); QDirModel *dirModelCompleter = new QDirModel(this); dirModelCompleter->setFilter( QDir::AllDirs/*QDir::Dirs*/ ); QCompleter *completer = new QCompleter( this ); completer->setModel( dirModelCompleter ); directoryComboBox->setCompleter( completer ); connect(directoryComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(changeDir(const QString&))); QToolButton *btnBrowse = new QToolButton(); btnBrowse->setIcon(QIcon(":/images/folderopen.png")); //btnBrowse->setIconSize( m_iconSize ); btnBrowse->setToolTip(tr("Select a new folder")); connect(btnBrowse, SIGNAL(clicked()), this, SLOT(browse())); QToolButton *btnBrowseUp = new QToolButton(); btnBrowseUp->setIcon(QIcon(":/images/up.png")); //btnBrowseUp->setIconSize( m_iconSize ); btnBrowseUp->setToolTip(tr("Navagate one level up")); connect(btnBrowseUp, SIGNAL(clicked()), this, SLOT(browseUp())); QHBoxLayout *dirLayout = new QHBoxLayout(); dirLayout->addWidget(directoryComboBox); dirLayout->addWidget(btnBrowseUp); dirLayout->addWidget(btnBrowse); dirLayout->addStretch(1); createFilesTree(); createFilesTable(); foundMessage = new QLabel(tr("No search results")); QHBoxLayout *toolLayout = setupToolLayout(); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addLayout(toolLayout); mainLayout->addLayout(dirLayout); mainLayout->addWidget(m_dirTree); mainLayout->addWidget(filesTable); mainLayout->addWidget(foundMessage); QDialog *centralDlg = new QDialog(); centralDlg->setModal( false ); centralDlg->setLayout( mainLayout ); setWidget( centralDlg ); }
//! [0] Window::Window(QWidget *parent) : QWidget(parent) { browseButton = createButton(tr("&Browse..."), SLOT(browse())); findButton = createButton(tr("&Find"), SLOT(find())); tinyAllButton = createButton(tr("&Tiny"), SLOT(tinyAll())); outBrowseButton = createButton(tr("&Browse..."), SLOT(browse2())); fileComboBox = createComboBox(tr("*")); textComboBox = createComboBox(); directoryComboBox = createComboBox(QDir::currentPath()); outDirectoryComboBox = createComboBox(QDir::currentPath()); tokenComboBox = createComboBox(tr("HyDxVk41AiyRezVSYFaycTqq1jwgDmm9")); fileLabel = new QLabel(tr("Named:")); textLabel = new QLabel(tr("Containing text:")); tokenLabel = new QLabel(tr("Token:")); directoryLabel = new QLabel(tr("In directory:")); outDirecotryLabel = new QLabel(tr("Out Directory")); filesFoundLabel = new QLabel; createFilesTable(); //! [0] //! [1] QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(fileLabel, 0, 0); mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); mainLayout->addWidget(textLabel, 1, 0); mainLayout->addWidget(textComboBox, 1, 1, 1, 2); mainLayout->addWidget(tokenLabel, 2, 0); mainLayout->addWidget(tokenComboBox, 2, 1, 1, 2); mainLayout->addWidget(directoryLabel, 3, 0); mainLayout->addWidget(directoryComboBox, 3, 1); mainLayout->addWidget(browseButton, 3, 2); mainLayout->addWidget(outDirecotryLabel, 4, 0); mainLayout->addWidget(outDirectoryComboBox, 4, 1); mainLayout->addWidget(outBrowseButton, 4, 2); mainLayout->addWidget(filesTable, 5, 0, 1, 3); mainLayout->addWidget(filesFoundLabel, 6, 1, 1, 2); mainLayout->addWidget(tinyAllButton, 6, 2); mainLayout->addWidget(findButton, 6, 0); setLayout(mainLayout); setWindowTitle(tr("*・゜゚・*:.。..。.:*・'(*゚▽゚*)'・*:.。. .。.:*・゜゚・*")); resize(700, 700); }
Window::Window(QWidget *parent) : QDialog(parent) { findButton = createButton("&Find", SLOT(find())); findButton->setDefault(true); browseButton = createButton("&Browse...", SLOT(browse())); fileComboBox = createComboBox("*"); textComboBox = createComboBox(); directoryComboBox = createComboBox(QDir::currentPath()); fileLabel = new QLabel("Named:"); textLabel = new QLabel("containing text:"); directoryLabel = new QLabel("In directory"); filesFoundLabel = new QLabel; createFilesTable(); QHBoxLayout *buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(findButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(fileLabel, 0, 0); mainLayout->addWidget(fileComboBox, 0, 1, 1,2); mainLayout->addWidget(textLabel, 1, 0); mainLayout->addWidget(textComboBox, 1, 1, 1,2); mainLayout->addWidget(directoryLabel, 2, 0); mainLayout->addWidget(directoryComboBox, 2, 1); mainLayout->addWidget(browseButton, 2, 2); mainLayout->addWidget(filesTable, 3, 0, 1, 3); mainLayout->addWidget(filesFoundLabel, 4, 0); mainLayout->addLayout(buttonsLayout, 5, 0, 1, 3); setLayout(mainLayout); setWindowTitle("Find Files"); resize(700, 300); }
//! [0] Window::Window(QWidget *parent) : QWidget(parent) { setWindowTitle(tr("Find Files")); QPushButton *browseButton = new QPushButton(tr("&Browse..."), this); connect(browseButton, &QAbstractButton::clicked, this, &Window::browse); findButton = new QPushButton(tr("&Find"), this); connect(findButton, &QAbstractButton::clicked, this, &Window::find); fileComboBox = createComboBox(tr("*")); connect(fileComboBox->lineEdit(), &QLineEdit::returnPressed, this, &Window::animateFindClick); textComboBox = createComboBox(); connect(textComboBox->lineEdit(), &QLineEdit::returnPressed, this, &Window::animateFindClick); directoryComboBox = createComboBox(QDir::toNativeSeparators(QDir::currentPath())); connect(directoryComboBox->lineEdit(), &QLineEdit::returnPressed, this, &Window::animateFindClick); filesFoundLabel = new QLabel; createFilesTable(); QGridLayout *mainLayout = new QGridLayout(this); mainLayout->addWidget(new QLabel(tr("Named:")), 0, 0); mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); mainLayout->addWidget(new QLabel(tr("Containing text:")), 1, 0); mainLayout->addWidget(textComboBox, 1, 1, 1, 2); mainLayout->addWidget(new QLabel(tr("In directory:")), 2, 0); mainLayout->addWidget(directoryComboBox, 2, 1); mainLayout->addWidget(browseButton, 2, 2); mainLayout->addWidget(filesTable, 3, 0, 1, 3); mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2); mainLayout->addWidget(findButton, 4, 2); //! [0] //! [1] connect(new QShortcut(QKeySequence::Quit, this), &QShortcut::activated, qApp, &QApplication::quit); //! [1] }
QString AddImagesDialog::getDirectory(const QStringList &fileNames, const QString &defaultDirectory) { QDialog *dialog = new QDialog(Core::ICore::dialogParent()); dialog->setMinimumWidth(480); QString result; QString directory = defaultDirectory; dialog->setModal(true); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); dialog->setWindowTitle(QCoreApplication::translate("AddImageToResources","Add Resources")); QTableWidget *table = createFilesTable(fileNames); table->setParent(dialog); QGridLayout *mainLayout = new QGridLayout(dialog); mainLayout->addWidget(table, 0, 0, 1, 4); QComboBox *directoryComboBox = createDirectoryComboBox(defaultDirectory); auto setDirectoryForComboBox = [directoryComboBox, &directory](const QString &newDir) { if (directoryComboBox->findText(newDir) < 0) directoryComboBox->addItem(newDir); directoryComboBox->setCurrentText(newDir); directory = newDir; }; QObject::connect(directoryComboBox, &QComboBox::currentTextChanged, dialog, [&directory](const QString &text){ directory = text; }); QPushButton *browseButton = new QPushButton(QCoreApplication::translate("AddImageToResources", "&Browse..."), dialog); QObject::connect(browseButton, &QPushButton::clicked, dialog, [setDirectoryForComboBox, &directory]() { const QString newDir = QFileDialog::getExistingDirectory(Core::ICore::dialogParent(), QCoreApplication::translate("AddImageToResources", "Target Directory"), directory); if (!newDir.isEmpty()) setDirectoryForComboBox(newDir); }); mainLayout->addWidget(new QLabel(QCoreApplication::translate("AddImageToResources", "In directory:")), 1, 0); mainLayout->addWidget(directoryComboBox, 1, 0, 1, 3); mainLayout->addWidget(browseButton, 1, 3, 1 , 1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); mainLayout->addWidget(buttonBox, 3, 2, 1, 2); QObject::connect(buttonBox, &QDialogButtonBox::accepted, dialog, [dialog](){ dialog->accept(); dialog->deleteLater(); }); QObject::connect(buttonBox, &QDialogButtonBox::rejected, dialog, [dialog, &directory](){ dialog->reject(); dialog->deleteLater(); directory = QString(); }); QObject::connect(dialog, &QDialog::accepted, [&directory, &result](){ result = directory; }); dialog->exec(); return result; }