Merge pull request #906 from openscad/text-fixes-5

Change FontDialog button to do "copy to clipboard".
master
Torsten Paul 2014-08-10 21:27:54 +02:00
commit eabd27dd92
5 changed files with 11 additions and 15 deletions

View File

@ -24,6 +24,7 @@
* *
*/ */
#include <QClipboard>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "FontListDialog.h" #include "FontListDialog.h"
@ -41,9 +42,12 @@ FontListDialog::~FontListDialog()
{ {
} }
void FontListDialog::on_pasteButton_clicked() void FontListDialog::on_copyButton_clicked()
{ {
font_selected(selection); font_selected(selection);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(selection);
} }
void FontListDialog::on_filterLineEdit_textChanged(const QString &text) void FontListDialog::on_filterLineEdit_textChanged(const QString &text)
@ -54,7 +58,7 @@ void FontListDialog::on_filterLineEdit_textChanged(const QString &text)
void FontListDialog::selection_changed(const QItemSelection &current, const QItemSelection &) void FontListDialog::selection_changed(const QItemSelection &current, const QItemSelection &)
{ {
if (current.count() == 0) { if (current.count() == 0) {
pasteButton->setEnabled(false); copyButton->setEnabled(false);
return; return;
} }
@ -62,12 +66,12 @@ void FontListDialog::selection_changed(const QItemSelection &current, const QIte
const QString name = model->item(idx.row(), 0)->text(); const QString name = model->item(idx.row(), 0)->text();
const QString style = model->item(idx.row(), 1)->text(); const QString style = model->item(idx.row(), 1)->text();
selection = QString("\"%1:style=%2\"").arg(name).arg(style); selection = QString("\"%1:style=%2\"").arg(name).arg(style);
pasteButton->setEnabled(true); copyButton->setEnabled(true);
} }
void FontListDialog::update_font_list() void FontListDialog::update_font_list()
{ {
pasteButton->setEnabled(false); copyButton->setEnabled(false);
if (proxy) { if (proxy) {
delete proxy; delete proxy;

View File

@ -18,7 +18,7 @@ public:
void update_font_list(); void update_font_list();
public slots: public slots:
void on_pasteButton_clicked(); void on_copyButton_clicked();
void on_filterLineEdit_textChanged(const QString &); void on_filterLineEdit_textChanged(const QString &);
void selection_changed(const QItemSelection &, const QItemSelection &); void selection_changed(const QItemSelection &, const QItemSelection &);

View File

@ -34,12 +34,12 @@
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QPushButton" name="pasteButton"> <widget class="QPushButton" name="copyButton">
<property name="toolTip"> <property name="toolTip">
<string>Paste font selector to Editor Window</string> <string>Paste font selector to Editor Window</string>
</property> </property>
<property name="text"> <property name="text">
<string>Paste</string> <string>Copy to Clipboard</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -126,7 +126,6 @@ private slots:
void compileEnded(); void compileEnded();
private slots: private slots:
void pasteText(const QString text);
void pasteViewportTranslation(); void pasteViewportTranslation();
void pasteViewportRotation(); void pasteViewportRotation();
void hideEditor(); void hideEditor();

View File

@ -1243,12 +1243,6 @@ void MainWindow::pasteViewportTranslation()
cursor.insertText(txt); cursor.insertText(txt);
} }
void MainWindow::pasteText(const QString text)
{
QTextCursor cursor = editor->textCursor();
cursor.insertText(text);
}
void MainWindow::pasteViewportRotation() void MainWindow::pasteViewportRotation()
{ {
QTextCursor cursor = editor->textCursor(); QTextCursor cursor = editor->textCursor();
@ -2292,7 +2286,6 @@ void MainWindow::helpFontInfo()
{ {
if (!this->font_list_dialog) { if (!this->font_list_dialog) {
FontListDialog *dialog = new FontListDialog(); FontListDialog *dialog = new FontListDialog();
connect(dialog, SIGNAL(font_selected(QString)), this, SLOT(pasteText(QString)));
this->font_list_dialog = dialog; this->font_list_dialog = dialog;
} }
this->font_list_dialog->update_font_list(); this->font_list_dialog->update_font_list();