QString SetPartFlagsOperation::description() const { if (PartitionTable::flagNames(newFlags()).size() == 0) return xi18nc("@info:status", "Clear flags for partition <filename>%1</filename>", flagPartition().deviceNode()); return xi18nc("@info:status", "Set flags for partition <filename>%1</filename> to \"%2\"", flagPartition().deviceNode(), PartitionTable::flagNames(newFlags()).join(QStringLiteral(","))); }
void PlanExecutor::integrityCheckFinished(KJob *pJob) { endSleepInhibit(); discardIntegrityNotification(); mIntegrityNotification = new KNotification(QStringLiteral("IntegrityCheckCompleted"), KNotification::Persistent); mIntegrityNotification->setTitle(xi18nc("@title:window", "Integrity Check Completed")); mIntegrityNotification->setText(pJob->errorText()); QStringList lAnswers; if(pJob->error() == BackupJob::ErrorWithLog) { lAnswers << xi18nc("@action:button", "Show log file"); connect(mIntegrityNotification, SIGNAL(action1Activated()), SLOT(showLog())); } else if(pJob->error() == BackupJob::ErrorSuggestRepair) { lAnswers << xi18nc("@action:button", "Yes"); lAnswers << xi18nc("@action:button", "No"); connect(mIntegrityNotification, SIGNAL(action1Activated()), SLOT(startRepairJob())); } mIntegrityNotification->setActions(lAnswers); connect(mIntegrityNotification, SIGNAL(action2Activated()), SLOT(discardIntegrityNotification())); connect(mIntegrityNotification, SIGNAL(closed()), SLOT(discardIntegrityNotification())); connect(mIntegrityNotification, SIGNAL(ignored()), SLOT(discardIntegrityNotification())); mIntegrityNotification->sendEvent(); if(mState == INTEGRITY_TESTING) { //only restore if nothing has changed during the run mState = mLastState; } emit stateChanged(); }
QString RestoreOperation::description() const { if (overwrittenPartition()) return xi18nc("@info/plain", "Restore partition from <filename>%1</filename> to <filename>%2</filename>", fileName(), overwrittenPartition()->deviceNode()); return xi18nc("@info/plain", "Restore partition on <filename>%1</filename> at %2 from <filename>%3</filename>", targetDevice().deviceNode(), Capacity::formatByteSize(restorePartition().firstSector() * targetDevice().logicalSectorSize()), fileName()); }
bool LibPartedPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) { Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path)); bool rval = false; PedPartition* pedPartition = (partition.roles().has(PartitionRole::Extended)) ? ped_disk_extended_partition(pedDisk()) : ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()); if (pedPartition) { if (PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), sector_start, sector_end - sector_start + 1)) { if (PedConstraint* pedConstraint = ped_constraint_exact(pedGeometry)) { if (ped_disk_set_partition_geom(pedDisk(), pedPartition, pedConstraint, sector_start, sector_end)) rval = true; else report.line() << xi18nc("@info:progress", "Could not set geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode()); ped_constraint_destroy(pedConstraint); } else report.line() << xi18nc("@info:progress", "Could not get constraint for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode()); ped_geometry_destroy(pedGeometry); } else report.line() << xi18nc("@info:progress", "Could not get geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode()); } else report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode()); return rval; }
bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& ptable) { PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData()); if (pedDiskType == nullptr) { report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not retrieve partition table type \"%1\" for <filename>%2</filename>.", ptable.typeName(), deviceNode()); return false; } PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData()); if (dev == nullptr) { report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not open backend device <filename>%1</filename>.", deviceNode()); return false; } PedDisk* disk = ped_disk_new_fresh(dev, pedDiskType); if (disk == nullptr) { report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not create a new partition table in the backend for device <filename>%1</filename>.", deviceNode()); return false; } return LibPartedPartitionTable::commit(disk); }
HgBackoutDialog::HgBackoutDialog(QWidget *parent) : DialogBase(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent) { // dialog properties this->setWindowTitle(xi18nc("@title:window", "<application>Hg</application> Backout")); okButton()->setText(xi18nc("@action:button", "Backout")); okButton()->setDisabled(true); // setupUI(); // Load saved settings FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); this->resize(QSize(settings->backoutDialogWidth(), settings->backoutDialogHeight())); // connections connect(this, SIGNAL(finished(int)), this, SLOT(saveGeometry())); connect(m_selectBaseCommitButton, SIGNAL(clicked()), this, SLOT(slotSelectBaseChangeset())); connect(m_selectParentCommitButton, SIGNAL(clicked()), this, SLOT(slotSelectParentChangeset())); connect(m_baseRevision, SIGNAL(textChanged(const QString&)), this, SLOT(slotUpdateOkButton(const QString&))); }
QString CreatePartitionJob::description() const { if (partition().number() > 0) return xi18nc("@info/plain", "Create new partition <filename>%1</filename>", partition().deviceNode()); return xi18nc("@info/plain", "Create new partition on device <filename>%1</filename>", device().deviceNode()); }
bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) { bool rval = false; #if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) { if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) { if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) { PedTimer* pedTimer = ped_timer_new(pedTimerHandler, nullptr); rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer); ped_timer_destroy(pedTimer); if (!rval) report.line() << xi18nc("@info:progress", "Could not resize file system on partition <filename>%1</filename>.", partition.deviceNode()); ped_geometry_destroy(resizedGeometry); } else report.line() << xi18nc("@info:progress", "Could not get geometry for resized partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode()); ped_file_system_close(pedFileSystem); } else report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode()); ped_geometry_destroy(originalGeometry); } else report.line() << xi18nc("@info:progress", "Could not read geometry for partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode()); #else Q_UNUSED(report); Q_UNUSED(partition); Q_UNUSED(newLength); #endif return rval; }
void HgBackoutDialog::setupUI() { m_mainGroup = new QGroupBox; m_baseRevision = new QLineEdit; m_parentRevision = new QLineEdit; m_optMerge = new QCheckBox(xi18nc("@label:checkbox", "Merge with old dirstate parent after backout")); m_selectParentCommitButton = new QPushButton(xi18nc("@label:button", "Select Changeset")); m_selectBaseCommitButton = new QPushButton(xi18nc("@label:button", "Select Changeset")); QGridLayout *mainGroupLayout = new QGridLayout; mainGroupLayout->addWidget(new QLabel(xi18nc("@label", "Revision to Backout: ")), 0, 0); mainGroupLayout->addWidget(m_baseRevision, 0, 1); mainGroupLayout->addWidget(m_selectBaseCommitButton, 0, 2); mainGroupLayout->addWidget(new QLabel(xi18nc("@label", "Parent Revision (optional): ")), 1, 0); mainGroupLayout->addWidget(m_parentRevision, 1, 1); mainGroupLayout->addWidget(m_selectParentCommitButton, 1, 2); mainGroupLayout->addWidget(m_optMerge, 2, 0, 1, 0); m_mainGroup->setLayout(mainGroupLayout); QVBoxLayout *lay = new QVBoxLayout; lay->addWidget(m_mainGroup); layout()->insertLayout(0, lay); }
bool ntfs::updateBootSector(Report& report, const QString& deviceNode) const { report.line() << xi18nc("@info:progress", "Updating boot sector for NTFS file system on partition <filename>%1</filename>.", deviceNode); quint32 n = firstSector(); char* s = reinterpret_cast<char*>(&n); #if Q_BYTE_ORDER == Q_BIG_ENDIAN std::swap(s[0], s[3]); std::swap(s[1], s[2]); #endif QFile device(deviceNode); if (!device.open(QFile::ReadWrite | QFile::Unbuffered)) { Log() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> for writing when trying to update the NTFS boot sector.", deviceNode); return false; } if (!device.seek(0x1c)) { Log() << xi18nc("@info:progress", "Could not seek to position 0x1c on partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); return false; } if (device.write(s, 4) != 4) { Log() << xi18nc("@info:progress", "Could not write new start sector to partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); return false; } Log() << xi18nc("@info:progress", "Updated NTFS boot sector for partition <filename>%1</filename> successfully.", deviceNode); return true; }
bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition& partition) { bool rval = false; if (PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector())) { if (pedPartition->type == PED_PARTITION_NORMAL || pedPartition->type == PED_PARTITION_LOGICAL) { if (ped_device_open(pedDevice())) { //reiser4 stores "ReIsEr4" at sector 128 with a sector size of 512 bytes // We need to use memset instead of = {0} because clang sucks. const long long zeroes_length = pedDevice()->sector_size*129; char zeroes[zeroes_length]; memset(zeroes, 0, zeroes_length*sizeof(char)); rval = ped_geometry_write(&pedPartition->geom, zeroes, 0, 129); if (!rval) report.line() << xi18nc("@info:progress", "Failed to erase filesystem signature on partition <filename>%1</filename>.", partition.deviceNode()); ped_device_close(pedDevice()); } } else rval = true; } else report.line() << xi18nc("@info:progress", "Could not delete file system on partition <filename>%1</filename>: Failed to get partition.", partition.deviceNode()); return rval; }
QString DeleteOperation::description() const { if (shredAction() != NoShred) return xi18nc("@info:status", "Shred partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name()); else return xi18nc("@info:status", "Delete partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name()); }
bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) const { Q_ASSERT(m_innerFs); if (mapperName().isEmpty()) return false; qint64 payloadLength = newLength - payloadOffset(); if ( newLength - length() * m_logicalSectorSize > 0 ) { ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() }); report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode); if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0) return m_innerFs->resize(report, mapperName(), payloadLength); } else if (m_innerFs->resize(report, mapperName(), payloadLength)) { ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("--size"), QString::number(payloadLength / m_logicalSectorSize), // LUKS assumes 512 bytes sector QStringLiteral("resize"), mapperName() }); report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode); if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0) return true; } report.line() << xi18nc("@info:progress", "Resizing encrypted file system on partition <filename>%1</filename> failed.", deviceNode); return false; }
void HgIgnoreWidget::setupUI() { QVBoxLayout *sideBar = new QVBoxLayout; m_addFiles = new QPushButton(xi18nc("@label:button", "Add Files")); m_addPattern = new QPushButton(xi18nc("@label:button", "Add Pattern")); m_editEntry = new QPushButton(xi18nc("@label:button", "Edit Entry")); m_removeEntries = new QPushButton(xi18nc("@label:button", "Remove Entries")); sideBar->addWidget(m_addFiles); sideBar->addWidget(m_addPattern); sideBar->addWidget(m_editEntry); sideBar->addWidget(m_removeEntries); sideBar->addStretch(); m_ignoreTable = new QListWidget; m_untrackedList = new QListWidget; setupUntrackedList(); m_ignoreTable->setSelectionMode(QListWidget::ExtendedSelection); m_untrackedList->setSelectionMode(QListWidget::ExtendedSelection); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(m_untrackedList); mainLayout->addWidget(m_ignoreTable); mainLayout->addLayout(sideBar); setLayout(mainLayout); connect(m_addFiles, SIGNAL(clicked()), this, SLOT(slotAddFiles())); connect(m_removeEntries, SIGNAL(clicked()), this, SLOT(slotRemoveEntries())); connect(m_addPattern, SIGNAL(clicked()), this, SLOT(slotAddPattern())); connect(m_editEntry, SIGNAL(clicked()), this, SLOT(slotEditEntry())); }
// dispatcher code for entering one of the available states void PlanExecutor::enterAvailableState() { if(mState == NOT_AVAILABLE) { mState = WAITING_FOR_FIRST_BACKUP; //initial child state of "Available" state emit stateChanged(); } bool lShouldBeTakenNow = false; bool lShouldBeTakenLater = false; int lTimeUntilNextWakeup; QString lUserQuestion; QDateTime lNow = QDateTime::currentDateTime().toUTC(); switch(mPlan->mScheduleType) { case BackupPlan::MANUAL: break; case BackupPlan::INTERVAL: { QDateTime lNextTime = mPlan->nextScheduledTime(); if(!lNextTime.isValid() || lNextTime < lNow) { lShouldBeTakenNow = true; if(!mPlan->mLastCompleteBackup.isValid()) lUserQuestion = xi18nc("@info", "Do you want to save a first backup now?"); else { QString t = KFormat().formatSpelloutDuration(mPlan->mLastCompleteBackup.secsTo(lNow) * 1000); lUserQuestion = xi18nc("@info", "It has been %1 since last backup was saved.\n" "Save a new backup now?", t); } } else { lShouldBeTakenLater = true; lTimeUntilNextWakeup = lNow.secsTo(lNextTime)*1000; } break; } case BackupPlan::USAGE: if(!mPlan->mLastCompleteBackup.isValid()) { lShouldBeTakenNow = true; lUserQuestion = xi18nc("@info", "Do you want to save a first backup now?"); } else if(mPlan->mAccumulatedUsageTime > (quint32)mPlan->mUsageLimit * 3600) { lShouldBeTakenNow = true; QString t = KFormat().formatSpelloutDuration(mPlan->mAccumulatedUsageTime * 1000); lUserQuestion = xi18nc("@info", "You have been active for %1 since last backup was saved.\n" "Save a new backup now?", t); } break; } if(lShouldBeTakenNow) { // Only ask the first time after destination has become available. // Always ask if power saving is active. if( (mPlan->mAskBeforeTakingBackup && mState == WAITING_FOR_FIRST_BACKUP) || powerSaveActive()) { askUser(lUserQuestion); } else { startBackupSaveJob(); } } else if(lShouldBeTakenLater){ // schedule a wakeup for asking again when the time is right. mSchedulingTimer->start(lTimeUntilNextWakeup); } }
void ViewListDocker::updateWindowTitle( bool modified ) { if ( modified ) { setWindowTitle( xi18nc( "@title:window", "View Selector [modified]" ) ); } else { setWindowTitle(xi18nc( "@title:window", "View Selector")); } }
QString LibPartedPartitionTable::createPartition(Report& report, const Partition& partition) { Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path)); QString rval = QString(); // According to libParted docs, PedPartitionType can be "nullptr if unknown". That's obviously wrong, // it's a typedef for an enum. So let's use something the libparted devs will hopefully never // use... PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff); if (partition.roles().has(PartitionRole::Extended)) pedType = PED_PARTITION_EXTENDED; else if (partition.roles().has(PartitionRole::Logical)) pedType = PED_PARTITION_LOGICAL; else if (partition.roles().has(PartitionRole::Primary)) pedType = PED_PARTITION_NORMAL; if (pedType == static_cast<int>(0xffffffff)) { report.line() << xi18nc("@info:progress", "Unknown partition role for new partition <filename>%1</filename> (roles: %2)", partition.deviceNode(), partition.roles().toString()); return QString(); } PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type()); PedPartition* pedPartition = ped_partition_new(pedDisk(), pedType, pedFsType, partition.firstSector(), partition.lastSector()); if (pedPartition == nullptr) { report.line() << xi18nc("@info:progress", "Failed to create new partition <filename>%1</filename>.", partition.deviceNode()); return QString(); } PedConstraint* pedConstraint = nullptr; PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length()); if (pedGeometry) pedConstraint = ped_constraint_exact(pedGeometry); ped_geometry_destroy(pedGeometry); if (pedConstraint == nullptr) { report.line() << i18nc("@info:progress", "Failed to create a new partition: could not get geometry for constraint."); return QString(); } if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint)) { char *pedPath = ped_partition_get_path(pedPartition); rval = QString::fromUtf8(pedPath); free(pedPath); } else { report.line() << xi18nc("@info:progress", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition.deviceNode(), QString::fromUtf8(pedDisk()->dev->path)); report.line() << LibPartedBackend::lastPartedExceptionMessage(); } ped_constraint_destroy(pedConstraint); return rval; }
KexiReportPart::KexiReportPart(QObject *parent, const QVariantList &l) : KexiPart::Part(parent, xi18nc("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). " "Use '_' character instead of spaces. First character should be a..z character. " "If you cannot use latin characters in your language, use english word.", "report"), xi18nc("tooltip", "Create new report"), xi18nc("what's this", "Creates new report."), l) , d(new Private) { setInternalPropertyValue("newObjectsAreDirty", true); }
bool SearchController::queryContinue( KFindDirection direction ) const { const QString messageBoxTitle = i18nc( "@title:window", "Find" ); const QString question = ( direction == FindForward ) ? xi18nc( "@info", "End of byte array reached.<nl/>Continue from the beginning?" ) : xi18nc( "@info", "Beginning of byte array reached.<nl/>Continue from the end?" ); const int answer = KMessageBox::questionYesNo( mParentWidget, question, messageBoxTitle, KStandardGuiItem::cont(), KStandardGuiItem::cancel() ); const bool result = ( answer != KMessageBox::No ); return result; }
void HgPluginSettingsWidget::setupUI() { m_diffProg = new QLineEdit; m_diffBrowseButton = new QPushButton(xi18nc("@label", "Browse")); QLabel *diffProgLabel = new QLabel(xi18nc("@label", "Visual Diff Executable")); QGridLayout *layout = new QGridLayout; layout->addWidget(diffProgLabel, 0, 0); layout->addWidget(m_diffProg, 0, 1); layout->addWidget(m_diffBrowseButton, 0, 2); layout->setRowStretch(layout->rowCount(), 1); setLayout(layout); }
bool RestoreOperation::execute(Report& parent) { bool rval = false; bool warning = false; Report* report = parent.newChild(description()); if (overwrittenPartition()) restorePartition().setPartitionPath(overwrittenPartition()->devicePath()); if (overwrittenPartition() || (rval = createPartitionJob()->run(*report))) { restorePartition().setState(Partition::StateNone); if ((rval = restoreJob()->run(*report))) { if ((rval = checkTargetJob()->run(*report))) { // If the partition was written over an existing one, the partition itself may now // be larger than the filesystem, so maximize the filesystem to the partition's size // or the image length, whichever is larger. If this fails, don't return an error, just // warn the user. if ((warning = !maximizeJob()->run(*report))) report->line() << xi18nc("@info/plain", "Warning: Maximizing file system on target partition <filename>%1</filename> to the size of the partition failed.", restorePartition().deviceNode()); } else report->line() << xi18nc("@info/plain", "Checking target file system on partition <filename>%1</filename> after the restore failed.", restorePartition().deviceNode()); } else { if (!overwrittenPartition()) DeletePartitionJob(targetDevice(), restorePartition()).run(*report); report->line() << i18nc("@info/plain", "Restoring file system failed."); } } else report->line() << i18nc("@info/plain", "Creating the destination partition to restore to failed."); if (rval) setStatus(warning ? StatusFinishedWarning : StatusFinishedSuccess); else setStatus(StatusError); report->setStatus(i18nc("@info/plain status (success, error, warning...) of operation", "%1: %2", description(), statusText())); return rval; }
void TreeLog::onSaveLog() { const QUrl url = QFileDialog::getSaveFileUrl(); if (!url.isEmpty()) { QTemporaryFile tempFile; if (!tempFile.open()) { KMessageBox::error(this, xi18nc("@info", "Could not create temporary output file to save <filename>%1</filename>.", url.fileName()), i18nc("@title:window", "Error Saving Log File")); return; } QTextStream stream(&tempFile); for (qint32 idx = 0; idx < treeLog().topLevelItemCount(); idx++) { QTreeWidgetItem* item = treeLog().topLevelItem(idx); stream << item->text(1) << ": " << item->text(2) << "\n"; } tempFile.close(); KIO::CopyJob* job = KIO::move(QUrl::fromLocalFile(tempFile.fileName()), url, KIO::HideProgressInfo); job->exec(); if ( job->error() ) job->ui()->showErrorMessage(); } }
void ScanProgressDialog::setDeviceName(const QString& d) { if (d.isEmpty()) setLabelText(i18nc("@label", "Scanning...")); else setLabelText(xi18nc("@label", "Scanning device: <filename>%1</filename>", d)); }
void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree) { QMenu headerMenu(xi18nc("@title:menu", "Columns")); QHeaderView* header = tree.header(); for (qint32 i = 0; i < tree.model()->columnCount(); i++) { const int idx = header->logicalIndex(i); const QString text = tree.model()->headerData(idx, Qt::Horizontal).toString(); QAction* action = headerMenu.addAction(text); action->setCheckable(true); action->setChecked(!header->isSectionHidden(idx)); action->setData(idx); action->setEnabled(idx > 0); } QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p)); if (action != nullptr) { const bool hidden = !action->isChecked(); tree.setColumnHidden(action->data().toInt(), hidden); if (!hidden) tree.resizeColumnToContents(action->data().toInt()); } }
void PasswordNeededQuery::execute() { qCDebug(ARK) << "Executing password prompt"; // If we are being called from the KPart, the cursor is probably Qt::WaitCursor // at the moment (#231974) QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); QPointer<KPasswordDialog> dlg = new KPasswordDialog; dlg.data()->setPrompt(xi18nc("@info", "The archive <filename>%1</filename> is password protected. Please enter the password.", m_data.value(QStringLiteral("archiveFilename")).toString())); if (m_data.value(QStringLiteral("incorrectTryAgain")).toBool()) { dlg.data()->showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError); } const bool notCancelled = dlg.data()->exec(); const QString password = dlg.data()->password(); m_data[QStringLiteral("password")] = password; setResponse(notCancelled && !password.isEmpty()); QApplication::restoreOverrideCursor(); delete dlg.data(); }
QVariant ProvidersModel::data(const QModelIndex& index, int role) const { if (index.isValid()) { if (role == Qt::CheckStateRole && index.column()==Preferred) return (m_favoriteEngines.contains(m_providers.at(index.row())->desktopEntryName()) ? Qt::Checked : Qt::Unchecked); if (role == Qt::DisplayRole) { if (index.column()==Name) return m_providers.at(index.row())->name(); if (index.column()==Shortcuts) return m_providers.at(index.row())->keys().join(QStringLiteral(",")); } if (role == Qt::ToolTipRole || role == Qt::WhatsThisRole) { if (index.column() == Preferred) return xi18nc("@info:tooltip", "Check this box to select the highlighted web shortcut " "as preferred.<nl/>Preferred web shortcuts are used in " "places where only a few select shortcuts can be shown " "at one time."); } if (role == Qt::UserRole) return index.row();//a nice way to bypass proxymodel } return QVariant(); }
void HgConfigDialog::setupUI() { m_generalConfig = new HgGeneralConfigWidget(m_configType); addPage(m_generalConfig, xi18nc("@label:group", "General Settings")); if (m_configType == HgConfig::RepoConfig) { m_pathConfig = new HgPathConfigWidget; addPage(m_pathConfig, xi18nc("@label:group", "Repository Paths")); m_ignoreWidget = new HgIgnoreWidget; addPage(m_ignoreWidget, xi18nc("@label:group", "Ignored Files")); } else if (m_configType == HgConfig::GlobalConfig) { m_pluginSetting = new HgPluginSettingsWidget; addPage(m_pluginSetting, xi18nc("@label:group", "Plugin Settings")); } }
HgUpdateDialog::HgUpdateDialog(QWidget *parent): DialogBase(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent) { // dialog properties this->setWindowTitle(xi18nc("@title:window", "<application>Hg</application> Update")); this->okButton()->setText(xi18nc("@action:button", "Update")); // UI QGroupBox *selectGroup = new QGroupBox(i18n("New working directory")); QVBoxLayout *selectLayout = new QVBoxLayout; m_selectType = new KComboBox; m_selectFinal = new KComboBox; m_selectType->addItem(i18n("Branch")); m_selectType->addItem(i18n("Tag")); m_selectType->addItem(i18n("Changeset/Revision")); selectLayout->addWidget(m_selectType); selectLayout->addWidget(m_selectFinal); selectGroup->setLayout(selectLayout); QGroupBox *infoGroup = new QGroupBox(i18n("Current Parent")); QVBoxLayout *infoLayout = new QVBoxLayout; m_currentInfo = new QLabel; infoLayout->addWidget(m_currentInfo); infoGroup->setLayout(infoLayout); QGroupBox *optionGroup = new QGroupBox(i18n("Options")); QVBoxLayout *optionLayout = new QVBoxLayout; m_discardChanges = new QCheckBox(i18n("Discard uncommitted changes")); m_discardChanges->setCheckState(Qt::Unchecked); optionLayout->addWidget(m_discardChanges); optionGroup->setLayout(optionLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(infoGroup); mainLayout->addWidget(selectGroup); mainLayout->addWidget(optionGroup); slotUpdateDialog(0); layout()->insertLayout(0, mainLayout); // connections connect(m_selectType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDialog(int))); }
GoToStackPageAction::GoToStackPageAction(Direction direction, KFormDesigner::Container *container, QWidget *receiver, QObject *parent) : QAction(QIcon::fromTheme(direction == Previous ? koIconName("go-previous") : koIconName("go-next")), direction == Previous ? xi18nc("Go to Previous Page of a Stacked Widget", "Go to Previous Page") : xi18nc("Go to Next Page of a Stacked Widget", "Go to Next Page"), parent) , m_direction(direction) , m_container(container) , m_receiver(receiver) { connect(this, SIGNAL(triggered()), this, SLOT(slotTriggered())); QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver); if (!stack || !stack->widget(nextWidgetIndex())) { setEnabled(false); } }
void HgBundleDialog::slotSelectChangeset() { DialogBase diag(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); diag.setWindowTitle(xi18nc("@title:window", "Select Changeset")); diag.okButton()->setText(xi18nc("@action:button", "Select")); diag.setMinimumWidth(700); m_commitInfo = new HgCommitInfoWidget; loadCommits(); diag.layout()->insertWidget(0, m_commitInfo); if (diag.exec() == QDialog::Accepted) { m_baseRevision->setText(m_commitInfo->selectedChangeset()); } }