"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/c2bSettings.cpp" between
cb2bib-1.9.9.tar.gz and cb2bib-2.0.0.tar.gz

About: cb2Bib is a multiplatform application for rapidly extracting unformatted, or unstandardized bibliographic references from email alerts, journal Web pages, and PDF files.

c2bSettings.cpp  (cb2bib-1.9.9):c2bSettings.cpp  (cb2bib-2.0.0)
/*************************************************************************** /***************************************************************************
* Copyright (C) 2004-2018 by Pere Constans * Copyright (C) 2004-2019 by Pere Constans
* constans@molspaces.com * constans@molspaces.com
* cb2Bib version 1.9.9. Licensed under the GNU GPL version 3. * cb2Bib version 2.0.0. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution. * See the LICENSE file that comes with this distribution.
***************************************************************************/ ***************************************************************************/
#include "c2bSettings.h" #include "c2bSettings.h"
#include "c2bUtils.h" #include "c2bUtils.h"
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QMessageBox> #include <QMessageBox>
#include <QProgressBar> #include <QProgressBar>
#include <QShortcut> #include <QShortcut>
#include <QTimer> #include <QTimer>
/** /**
Global settings for cb2Bib Global settings for cb2Bib
*/ */
c2bSettings::c2bSettings(const QString& organization, const QString& application , QObject* parento) c2bSettings::c2bSettings(const QString& organization, const QString& application , QObject* parento)
: settings(organization, application, parento), _progress_bar(0) : settings(organization, application, parento), _progress_bar(0) {}
{}
c2bSettings::c2bSettings(const QString& fn, QObject* parento) : settings(fn, par c2bSettings::c2bSettings(const QString& fn, QObject* parento) : settings(fn, par
ento), _progress_bar(0) ento), _progress_bar(0) {}
{}
c2bSettings::~c2bSettings() c2bSettings::~c2bSettings()
{ {
delete _progress_bar; delete _progress_bar;
} }
c2bSettings* c2bSettings::initSettings() c2bSettings* c2bSettings::initSettings()
{ {
c2bSettings* s; c2bSettings* s;
if (c2bSettings::isConfiguredMode()) if (c2bSettings::isConfiguredMode())
skipping to change at line 155 skipping to change at line 153
return; return;
QHash<QString, QKeySequence>::const_iterator it(keysequences.constBegin()); QHash<QString, QKeySequence>::const_iterator it(keysequences.constBegin());
while (it != keysequences.constEnd()) while (it != keysequences.constEnd())
{ {
setValue(it.key(), it.value()); setValue(it.key(), it.value());
++it; ++it;
} }
// Set keysequences to created objects // Set keysequences to created objects
const QString sctag("Shortcuts/"); const QString sctag("Shortcuts/");
foreach(QWidget * w, QApplication::topLevelWidgets()) foreach (QWidget* w, QApplication::topLevelWidgets())
{ {
const QList<QAction*> alist(w->findChildren<QAction*>()); const QList<QAction*> alist(w->findChildren<QAction*>());
for (int i = 0; i < alist.count(); ++i) for (int i = 0; i < alist.count(); ++i)
{ {
const QString fullname(alist.at(i)->data().toString()); const QString fullname(alist.at(i)->data().toString());
if (fullname.startsWith(sctag)) if (fullname.startsWith(sctag))
alist.at(i)->setShortcut(keysequence(fullname)); alist.at(i)->setShortcut(keysequence(fullname));
} }
const QList<QShortcut*> sclist(w->findChildren<QShortcut*>()); const QList<QShortcut*> sclist(w->findChildren<QShortcut*>());
for (int i = 0; i < sclist.count(); ++i) for (int i = 0; i < sclist.count(); ++i)
{ {
const QString fullname(sclist.at(i)->objectName()); const QString fullname(sclist.at(i)->objectName());
if (fullname.startsWith(sctag)) if (fullname.startsWith(sctag))
sclist.at(i)->setKey(keysequence(fullname)); sclist.at(i)->setKey(keysequence(fullname));
} }
} }
} }
void c2bSettings::setKeysequence(const QString& path, QAction* action) void c2bSettings::setKeysequence(const QString& path, QAction* action)
{ {
if (!action) if (!action)
return; return;
const QString fullname(path + action->text()); const QString fullname(path + action->text());
if (_default_keysequences.contains(fullname)) if (_default_keysequences.contains(fullname))
{ {
action->setShortcut(keysequence(fullname)); action->setShortcut(keysequence(fullname));
action->setData(fullname); action->setData(fullname);
} }
else else
c2bUtils::warn(tr("Action '%1' is not registered in default keysequence list").arg(fullname)); c2bUtils::warn(tr("Action '%1' is not registered in default keysequence list").arg(fullname));
} }
void c2bSettings::setKeysequence(const QString& fullname, QShortcut* shortcut) void c2bSettings::setKeysequence(const QString& fullname, QShortcut* shortcut)
{ {
if (!shortcut) if (!shortcut)
return; return;
if (_default_keysequences.contains(fullname)) if (_default_keysequences.contains(fullname))
{ {
shortcut->setObjectName(fullname); shortcut->setObjectName(fullname);
shortcut->setKey(keysequence(fullname)); shortcut->setKey(keysequence(fullname));
} }
else else
c2bUtils::warn(tr("Shortcut '%1' is not registered in default keysequenc e list").arg(fullname)); c2bUtils::warn(tr("Shortcut '%1' is not registered in default keysequenc e list").arg(fullname));
skipping to change at line 240 skipping to change at line 238
// from having multiple cb2Bib instances in its usual deployment, if so desi red. // from having multiple cb2Bib instances in its usual deployment, if so desi red.
// Aware of QClipboard X11 note: "You should not store or retrieve the clipb oard contents in response // Aware of QClipboard X11 note: "You should not store or retrieve the clipb oard contents in response
// to timer or non-user-input events". Functions processReferenceFile() and processprocessReferenceFileEvent() // to timer or non-user-input events". Functions processReferenceFile() and processprocessReferenceFileEvent()
// do not follow it. It seems to work smooth, for all platforms, and, overal l, it is a feasible solution // do not follow it. It seems to work smooth, for all platforms, and, overal l, it is a feasible solution
// in this particular case. // in this particular case.
QFile file(cl_import_filename); QFile file(cl_import_filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
cl_cb2bib_import_mode = true; cl_cb2bib_import_mode = true;
QMessageBox::warning(0, tr("Warning - cb2Bib"), tr("Unable to open the r QMessageBox::warning(0, tr("Warning - cb2Bib"),
eference file %1 for reading.\nError: '%2'."). tr("Unable to open the reference file %1 for readin
arg(cl_import_filename).arg(file.errorString()), QM g.\nError: '%2'.")
essageBox::Ok); .arg(cl_import_filename, file.errorString()),
QMessageBox::Ok);
QTimer::singleShot(500, qApp, SLOT(quit())); QTimer::singleShot(500, qApp, SLOT(quit()));
} }
else else
{ {
if (value("cb2Bib/isRunning", false).toBool()) if (value("cb2Bib/isRunning", false).toBool())
{ {
cl_cb2bib_import_mode = true; cl_cb2bib_import_mode = true;
if (!_progress_bar) if (!_progress_bar)
_progress_bar = new QProgressBar; _progress_bar = new QProgressBar;
_progress_bar->setRange(0, 100); _progress_bar->setRange(0, 100);
_progress_bar->setWindowTitle(QObject::tr("Importing...")); _progress_bar->setWindowTitle(QObject::tr("Importing..."));
_progress_bar->setWindowIcon(QIcon(QString::fromUtf8(":/icons/icons/ cb2bib.png")));
_progress_bar->show(); _progress_bar->show();
_progress_bar->setValue(50); _progress_bar->setValue(50);
} }
QTimer::singleShot(500, this, SLOT(processReferenceFileEvent())); QTimer::singleShot(500, this, SLOT(processReferenceFileEvent()));
} }
} }
void c2bSettings::processReferenceFileEvent() void c2bSettings::processReferenceFileEvent()
{ {
const QString reference(c2bUtils::fileToString(cl_import_filename).trimmed() ); const QString reference(c2bUtils::fileToString(cl_import_filename).trimmed() );
 End of changes. 9 change blocks. 
15 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)