void TodoDialog::setupUi() { setupMainSplitter(); loadTodoListData(); ui->todoItemLoadingProgressBar->hide(); QSettings settings; { const QSignalBlocker blocker(ui->showCompletedItemsCheckBox); Q_UNUSED(blocker); bool showCompletedItems = settings.value("TodoDialog/showCompletedItems").toBool(); ui->showCompletedItemsCheckBox->setChecked(showCompletedItems); } int index = CalendarItem::getCurrentCalendarIndex(); if (index >= 0) { const QSignalBlocker blocker(ui->todoListSelector); Q_UNUSED(blocker); // set the index of the todo list selector if we found it ui->todoListSelector->setCurrentIndex(index); } else { // if we didn't find the index store the new current item settings.setValue("TodoDialog/todoListSelectorSelectedItem", ui->todoListSelector->currentText()); } // hide the reminder date time select ui->reminderDateTimeEdit->hide(); // now load the todo list items reloadTodoList(); // installEventFilter(this); ui->newItemEdit->installEventFilter(this); ui->newItemEdit->setFocus(); }
TrashDialog::TrashDialog(QScriptValue notes, MainWindow *mainWindow, QWidget *parent) : QDialog(parent), ui(new Ui::TrashDialog) { this->mainWindow = mainWindow; ui->setupUi(this); setupMainSplitter(); QPushButton *button; ui->buttonBox->clear(); button = new QPushButton( tr( "&Restore selected note on server" ) ); button->setToolTip( "<h3>Slower, but with note versions</h3><p>The note will be restored on your ownCloud server with all versions.</p><p>You will have to wait until it is synced to QOwnNotes by ownCloud sync.</p>" ); button->setProperty( "ActionRole", RestoreOnServer ); button->setDefault( false ); button->setIcon( QIcon( ":/images/breeze/view-restore.svg" ) ); ui->buttonBox->addButton( button, QDialogButtonBox::ActionRole ); button = new QPushButton( tr( "&Download selected note" ) ); button->setToolTip( "<h3>Faster, but without versions</h3><p>The note will be created with the text from the preview.</p><p>The note versions on your ownCloud server will not be restored and the note will remain in the trash.</p><p>You can always restore the note and it's version later.</p>" ); button->setProperty( "ActionRole", Download ); button->setDefault( false ); button->setIcon( QIcon( ":/images/breeze/edit-download.svg" ) ); ui->buttonBox->addButton( button, QDialogButtonBox::ActionRole ); button = new QPushButton( tr( "&Cancel" ) ); button->setProperty( "ActionRole", Cancel ); button->setIcon( QIcon( ":/images/breeze/dialog-cancel.svg" ) ); button->setDefault( true ); ui->buttonBox->addButton( button, QDialogButtonBox::ActionRole ); connect( this->ui->buttonBox, SIGNAL( clicked( QAbstractButton* ) ), SLOT( dialogButtonClicked( QAbstractButton* ) ) ); connect( this, SIGNAL( finished(int) ), this, SLOT( storeSettings() ) ); QString itemName; QString dateString; QString data; int timestamp; ui->trashListWidget->clear(); dataList = new QStringList(); timestampList = new QList<int>; // init the iterator for the verions QScriptValueIterator notesIterator( notes ); // iterate over the trashs while ( notesIterator.hasNext() ) { notesIterator.next(); // qDebug() << notesIterator.value().property( "timestamp" ).toString() << " - " << notesIterator.value().property( "dateString" ).toString() << " - " << notesIterator.value().property( "noteName" ).toString(); itemName = notesIterator.value().property( "noteName" ).toString(); dateString = notesIterator.value().property( "dateString" ).toString(); data = notesIterator.value().property( "data" ).toString(); timestamp = notesIterator.value().property( "timestamp" ).toInteger(); if ( itemName == "" ) { continue; } QListWidgetItem *item = new QListWidgetItem(); item->setText( itemName ); item->setToolTip( dateString ); ui->trashListWidget->addItem( item ); dataList->append( data ); timestampList->append( timestamp ); } ui->trashListWidget->setCurrentRow( 0 ); ui->noteBrowser->setText( dataList->at( 0 ) ); }
void TodoDialog::setupUi() { setupMainSplitter(); refreshUi(); ui->newItemEdit->installEventFilter(this); ui->todoList->installEventFilter(this); ui->reminderDateTimeEdit->installEventFilter(this); ui->newItemEdit->setFocus(); // adding shortcuts, that weren't working when defined in the ui file QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+S"), this); QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_saveButton_clicked())); shortcut = new QShortcut(QKeySequence("Ctrl+I"), this); QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(onSaveAndInsertButtonClicked())); shortcut = new QShortcut(QKeySequence("Ctrl+R"), this); QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_removeButton_clicked())); /* * setup the note button menu */ QMenu *noteMenu = new QMenu(); QAction *insertAction = noteMenu->addAction( tr("Save and insert into note")); insertAction->setIcon(QIcon::fromTheme( "document-save", QIcon(":icons/breeze-qownnotes/16x16/document-save.svg"))); insertAction->setToolTip(tr("Save the current todo item and insert a link" " to it into the current note")); connect(insertAction, SIGNAL(triggered()), this, SLOT(onSaveAndInsertButtonClicked())); QAction *importAction = noteMenu->addAction(tr("Import as note")); importAction->setIcon(QIcon::fromTheme( "document-import", QIcon(":icons/breeze-qownnotes/16x16/document-import.svg"))); importAction->setToolTip(tr("Import the current todo item as new note")); connect(importAction, SIGNAL(triggered()), this, SLOT(onImportAsNoteButtonClicked())); ui->noteButton->setMenu(noteMenu); /* * setup the reload button menu */ QMenu *reloadMenu = new QMenu(); QAction *reloadAction = reloadMenu->addAction(tr("Reload from server")); reloadAction->setIcon(QIcon::fromTheme( "view-refresh", QIcon(":icons/breeze-qownnotes/16x16/view-refresh.svg"))); reloadAction->setToolTip(tr("Reload tasks from server")); connect(reloadAction, SIGNAL(triggered()), this, SLOT(reloadTodoList())); QAction *clearCacheAction = reloadMenu->addAction( tr("Clear cache and reload")); clearCacheAction->setIcon(QIcon::fromTheme( "trash-empty", QIcon(":icons/breeze-qownnotes/16x16/trash-empty.svg"))); clearCacheAction->setToolTip(tr("Clear calendar cache and reload tasks " "from server")); connect(clearCacheAction, SIGNAL(triggered()), this, SLOT(clearCacheAndReloadTodoList())); ui->reloadTodoListButton->setMenu(reloadMenu); }
VersionDialog::VersionDialog(QScriptValue versions, MainWindow *mainWindow, QWidget *parent) : MasterDialog(parent), ui(new Ui::VersionDialog) { this->mainWindow = mainWindow; ui->setupUi(this); setupMainSplitter(); QPushButton *button; ui->buttonBox->clear(); button = new QPushButton( tr( "&Restore selected version" ) ); button->setProperty( "ActionRole", Restore ); button->setDefault( false ); button->setIcon( QIcon( ":/images/breeze/edit-download.svg" ) ); ui->buttonBox->addButton( button, QDialogButtonBox::ActionRole ); button = new QPushButton( tr( "&Cancel" ) ); button->setProperty( "ActionRole", Cancel ); button->setIcon( QIcon( ":/images/breeze/dialog-cancel.svg" ) ); button->setDefault( true ); ui->buttonBox->addButton( button, QDialogButtonBox::ActionRole ); connect( this->ui->buttonBox, SIGNAL( clicked( QAbstractButton* ) ), SLOT( dialogButtonClicked( QAbstractButton* ) ) ); connect( this, SIGNAL( finished(int) ), this, SLOT( storeSettings() ) ); QString itemName; QString diffHtml; ui->versionListWidget->clear(); diffList = new QStringList(); dataList = new QStringList(); // init the iterator for the verions QScriptValueIterator versionsIterator( versions ); // iterate over the versions while ( versionsIterator.hasNext() ) { versionsIterator.next(); // qDebug() << versionsIterator.name() << ": " << versionsIterator.value().property( "timestamp" ).toString() << " - " << versionsIterator.value().property( "humanReadableTimestamp" ).toString() << " - " << versionsIterator.value().property( "diffHtml" ).toString(); itemName = versionsIterator.value().property( "humanReadableTimestamp" ).toString(); if ( itemName == "" ) { continue; } diffHtml = versionsIterator.value().property( "diffHtml" ).toString(); diffHtml.replace( "<ins>", "<span style='background-color: rgb(214, 255, 199)'>" ); diffHtml.replace( "</ins>", "</span>" ); diffHtml.replace( "<del>", "<span style='background-color: rgb(255, 215, 215)'>" ); diffHtml.replace( "</del>", "</span>" ); diffHtml.replace( "\n", "<br />" ); ui->versionListWidget->addItem( itemName ); diffList->append( diffHtml ); dataList->append( versionsIterator.value().property( "data" ).toString() ); } ui->versionListWidget->setCurrentRow( 0 ); ui->diffBrowser->setHtml( diffList->at( 0 ) ); }