// TODO: Refactor formRootList fucntions and function FormFolders::makeRootFolder. void FormListOfFiles::formRootList(QString json){ QStringList rootFoldersList, rootList; QSettings generalSettings("SimpleDrive", "General"); QString rootPath = generalSettings.value("rootDir").toString(); QSettings s("SimpleDrive", "Files"); s.setIniCodec("UTF-8"); QJsonDocument jd = QJsonDocument::fromJson(json.toUtf8()); QJsonObject globalObject = jd.object(); QJsonArray arrayWithItems(globalObject["items"].toArray()); for(auto iter = arrayWithItems.begin();iter!=arrayWithItems.end(); ++iter) { QJsonObject file = (*iter).toObject(); QJsonObject labels_object = file["labels"].toObject(); if(!labels_object["trashed"].toBool()){ s.beginGroup(file["id"].toString()); s.setValue("Path", rootPath); s.setValue("title", file["title"].toString()); s.setValue("modifiedDate", file["modifiedDate"].toString()); s.setValue("icon", file["iconLink"].toString().mid(44)); QJsonArray parents_array(file["parents"].toArray()); QJsonObject parent_object = parents_array.first().toObject(); s.setValue("parentId", parent_object["id"].toString()); if(file["mimeType"].toString() == "application/vnd.google-apps.folder"){ rootFoldersList.push_back(file["id"].toString()); } else { rootList.push_back(file["id"].toString()); if(file["mimeType"].toString().contains("google")){ // TODO: Save links as a file for online files. s.setValue("downloadUrl", file["alternateLink"].toString()); s.setValue("online", true); } else { s.setValue("downloadUrl", file["downloadUrl"].toString()); } s.setValue("originalFilename", file["originalFilename"].toString()); s.setValue("fileExtension", file["fileExtension"].toString()); s.setValue("md5Checksum", file["md5Checksum"].toString()); s.setValue("fileSize", file["fileSize"].toString()); } s.endGroup(); addRootQTreeWidgetItem(file["id"].toString(), &s, rootPath); } } if(!rootFoldersList.empty()) s.setValue("rootFolders", rootFoldersList); if(!rootList.empty()) s.setValue("rootFiles", rootList); // FormFolders *ff = new FormFolders(); // if(!folderListInRoot.isEmpty()) ff->getFolderList(folderListInRoot.first()); cleanUpFilesList(); generalSettings.setValue("listFormed", true); }
void app::applySetting(string name, string value) { //All setting checkers are functions //Return true if setting was set //Best practice to end setting checker with //else //{ // return false; //} //return true; if(generalSettings(name,value)) return; if(chirpSettings(name,value)) return; //Add more settings above here as else ifs else { cout << "Unrecognized setting from GUI form: " << name << ":" << value << endl; } }
void FormListOfFiles::cleanUpFilesList(){ QSettings s("SimpleDrive", "Files"); s.setIniCodec("UTF-8"); int totalSize=0; QStringList FilesList = s.value("filesInFolders").toStringList(); QStringList cleanedFilesList; for(auto iter = FilesList.begin();iter!=FilesList.end();iter++){ s.beginGroup(*iter); if(s.contains("Path")){ totalSize+=s.value("fileSize").toInt(); s.endGroup(); cleanedFilesList.push_back(*iter); } else { s.endGroup(); s.remove(*iter); } } QSettings generalSettings("SimpleDrive", "General"); generalSettings.setValue("totalSize", totalSize); s.setValue("filesInFolders", cleanedFilesList); }
bool ColorPickerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments); Q_UNUSED(errorMessage); auto optionsPage = new ColorPickerOptionsPage; d->generalSettings = optionsPage->generalSettings(); connect(optionsPage, &ColorPickerOptionsPage::generalSettingsChanged, this, &ColorPickerPlugin::onGeneralSettingsChanged); // Register the plugin actions ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *myContainer = ActionManager::createMenu("ColorPicker"); QMenu *myMenu = myContainer->menu(); myMenu->setTitle(tr("&ColorPicker")); myMenu->setEnabled(true); auto triggerColorEditAction = new QAction(tr(Constants::ACTION_NAME_TRIGGER_COLOR_EDIT), this); Command *command = ActionManager::registerAction(triggerColorEditAction, Constants::TRIGGER_COLOR_EDIT); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+C"))); myContainer->addAction(command); connect(triggerColorEditAction, &QAction::triggered, this, &ColorPickerPlugin::onColorEditTriggered); toolsContainer->addMenu(myContainer); // Register objects addAutoReleasedObject(optionsPage); return true; }
void TxtGenerator::addPages( KConfigDialog* dlg ) { Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); dlg->addPage( widget, generalSettings(), i18n("Txt"), "text-plain", i18n("Txt Backend Configuration") ); }
void KOOOGenerator::addPages( KConfigDialog* dlg ) { Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); dlg->addPage( widget, generalSettings(), i18n("OpenDocument Text"), "application-vnd.oasis.opendocument.text", i18n("OpenDocument Text Backend Configuration") ); }
void EPubGenerator::addPages( KConfigDialog* dlg ) { Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); dlg->addPage( widget, generalSettings(), i18n("EPub"), "application-epub+zip", i18n("EPub Backend Configuration") ); }
bool DocumentDataManager::SaveGeneralSettings() { return generalSettings().save( getGeneralSettingsFilePath() ); }
bool DocumentDataManager::LoadGeneralSettings() { return generalSettings().load( getGeneralSettingsFilePath() ); }
void FictionBookGenerator::addPages( KConfigDialog* dlg ) { Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); dlg->addPage( widget, generalSettings(), i18n("FictionBook"), QStringLiteral("okular-fb2"), i18n("FictionBook Backend Configuration") ); }