diff options
Diffstat (limited to 'source/fb2dlgs.cpp')
-rw-r--r-- | source/fb2dlgs.cpp | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/source/fb2dlgs.cpp b/source/fb2dlgs.cpp index 0c96f14..9dd9e26 100644 --- a/source/fb2dlgs.cpp +++ b/source/fb2dlgs.cpp @@ -166,144 +166,3 @@ FbSetupDlg::FbSetupDlg(QWidget *parent) { ui->setupUi(this); } - -//--------------------------------------------------------------------------- -// FbComboCtrl -//--------------------------------------------------------------------------- - -FbComboCtrl::FbComboCtrl(QWidget *parent) - : QLineEdit(parent) -{ - button = new QToolButton(this); - button->setCursor(Qt::ArrowCursor); - button->setFocusPolicy(Qt::NoFocus); - connect(button, SIGNAL(clicked()), SIGNAL(popup())); - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(button, 0, Qt::AlignRight); - layout->setSpacing(0); - layout->setMargin(0); -} - -void FbComboCtrl::resizeEvent(QResizeEvent* event) -{ - QLineEdit::resizeEvent(event); - QMargins margins(0, 0, button->width(), 0); - setTextMargins(margins); -} - -void FbComboCtrl::setIcon(const QIcon &icon) -{ - button->setIcon(icon); -} - -//--------------------------------------------------------------------------- -// FbImageDlg::FbTab -//--------------------------------------------------------------------------- - -FbImageDlg::FbTab::FbTab(QWidget* parent, QAbstractItemModel *model) - : QWidget(parent) - , combo(0) - , edit(0) -{ - QGridLayout * layout = new QGridLayout(this); - - label = new QLabel(this); - label->setText(tr("File name:")); - layout->addWidget(label, 0, 0, 1, 1); - - QWidget *control; - if (model) { - control = combo = new QComboBox(this); - combo->setModel(model); - } else { - control = edit = new FbComboCtrl(this); - } - - QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - control->setSizePolicy(sizePolicy); - layout->addWidget(control, 0, 1, 1, 1); - - QFrame *frame = new FbTextFrame(this); - frame->setMinimumSize(QSize(300, 200)); - layout->addWidget(frame, 1, 0, 1, 2); - - preview = new QWebView(this); - frame->layout()->addWidget(preview); -} - -//--------------------------------------------------------------------------- -// FbImageDlg -//--------------------------------------------------------------------------- - -FbImageDlg::FbImageDlg(FbTextEdit *text) - : QDialog(text) - , tabFile(0) - , tabPict(0) -{ - setWindowTitle(tr("Insert picture")); - - QLayout *layout = new QVBoxLayout(this); - - notebook = new QTabWidget(this); - layout->addWidget(notebook); - - QDialogButtonBox *buttons = new QDialogButtonBox(this); - buttons->setOrientation(Qt::Horizontal); - buttons->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); - layout->addWidget(buttons); - - connect(buttons, SIGNAL(accepted()), SLOT(accept())); - connect(buttons, SIGNAL(rejected()), SLOT(reject())); - connect(notebook, SIGNAL(currentChanged(int)), SLOT(notebookChanged(int))); - - QUrl url = text->url(); - - tabFile = new FbTab(notebook); - tabFile->edit->setIcon(FbIcon("document-open")); - tabFile->preview->setHtml(QString(), url); - connect(tabFile->edit, SIGNAL(popup()), SLOT(selectFile())); - notebook->addTab(tabFile, tr("Select file")); - - if (text->store()->count()) { - FbListModel *model = new FbListModel(text, this); - tabPict = new FbTab(notebook, model); - tabPict->preview->setHtml(QString(), url); - tabPict->combo->setCurrentIndex(0); - tabPict->preview->page()->setNetworkAccessManager(text->page()->networkAccessManager()); - notebook->addTab(tabPict, tr("From collection")); - connect(tabPict->combo, SIGNAL(activated(QString)), SLOT(pictureActivated(QString))); - } - - tabFile->edit->setFocus(); - resize(minimumSizeHint()); -} - -void FbImageDlg::notebookChanged(int index) -{ - if (index) { - disconnect(notebook, SIGNAL(currentChanged(int)), this, SLOT(notebookChanged(int))); - if (tabPict) pictureActivated(tabPict->combo->itemText(0)); - } -} - -void FbImageDlg::selectFile() -{ - QString filters; - filters += tr("Common Graphics (*.png *.jpg *.jpeg *.gif)") += ";;"; - filters += tr("Portable Network Graphics (PNG) (*.png)") += ";;"; - filters += tr("JPEG (*.jpg *.jpeg)") += ";;"; - filters += tr("Graphics Interchange Format (*.gif)") += ";;"; - filters += tr("All Files (*)"); - QWidget *p = qobject_cast<QWidget*>(parent()); - QString path = QFileDialog::getOpenFileName(p, tr("Insert image..."), QString(), filters); - if (!path.isEmpty()) tabFile->edit->setText(path); -} - -void FbImageDlg::pictureActivated(const QString & text) -{ - QUrl url = tabPict->preview->url(); - url.setFragment(text); - QString html = QString("<img src=%1 valign=center align=center width=100%>").arg(url.toString()); - tabPict->preview->setHtml(html, tabPict->preview->url()); -} - |