OSDN Git Service

Added "Copy" and "Paste" to custom context menu.
authorlordmulder <mulder2@gmx.de>
Thu, 16 Feb 2012 13:33:26 +0000 (14:33 +0100)
committerlordmulder <mulder2@gmx.de>
Thu, 16 Feb 2012 13:33:26 +0000 (14:33 +0100)
res/buttons/page_copy.png [new file with mode: 0644]
res/resources.qrc
src/version.h
src/win_addJob.cpp
src/win_addJob.h

diff --git a/res/buttons/page_copy.png b/res/buttons/page_copy.png
new file mode 100644 (file)
index 0000000..195dc6d
Binary files /dev/null and b/res/buttons/page_copy.png differ
index 20d1920..193bb53 100644 (file)
@@ -21,6 +21,7 @@
     <file>buttons/hourglass.png</file>
     <file>buttons/information.png</file>
     <file>buttons/lightning.png</file>
+    <file>buttons/page_copy.png</file>
     <file>buttons/page_edit.png</file>
     <file>buttons/page_paste.png</file>
     <file>buttons/pause.png</file>
index 51d670b..68499d8 100644 (file)
@@ -22,7 +22,7 @@
 #define VER_X264_MAJOR 2
 #define VER_X264_MINOR 0
 #define VER_X264_PATCH 2
-#define VER_X264_BUILD 209
+#define VER_X264_BUILD 216
 
 #define VER_X264_MINIMUM_REV 2146
 #define VER_X264_CURRENT_API 120
index 2ebb55c..48dbf9f 100644 (file)
@@ -38,6 +38,7 @@
 #include <QSettings>
 #include <QUrl>
 #include <QAction>
+#include <QClipboard>
 
 #define VALID_DIR(PATH) ((!(PATH).isEmpty()) && QFileInfo(PATH).exists() && QFileInfo(PATH).isDir())
 
        } \
 }
 
+#define ADD_CONTEXTMENU_ACTION(WIDGET, ICON, TEXT, SLOTNAME) \
+{ \
+       QAction *_action = new QAction((ICON), (TEXT), this); \
+       _action->setData(QVariant::fromValue<void*>(WIDGET)); \
+       WIDGET->addAction(_action); \
+       connect(_action, SIGNAL(triggered(bool)), this, SLOT(SLOTNAME())); \
+}
+
+#define ADD_CONTEXTMENU_SEPARATOR(WIDGET) \
+{ \
+       QAction *_action = new QAction(this); \
+       _action->setSeparator(true); \
+       WIDGET->addAction(_action); \
+} 
+
 ///////////////////////////////////////////////////////////////////////////////
 // Validator
 ///////////////////////////////////////////////////////////////////////////////
@@ -222,14 +238,14 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64suppo
        connect(editCustomAvs2YUVParams, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));
 
        //Create context menus
-       QAction *editorActionX264 = new QAction(QIcon(":/buttons/page_edit.png"), tr("Open Editor"), this);
-       editorActionX264->setData(QVariant::fromValue<void*>(editCustomX264Params));
-       editCustomX264Params->addAction(editorActionX264);
-       connect(editorActionX264, SIGNAL(triggered(bool)), this, SLOT(editorActionTriggered()));
-       QAction *editorActionAvs2YUV = new QAction(QIcon(":/buttons/page_edit.png"), tr("Open Editor"), this);
-       editorActionAvs2YUV->setData(QVariant::fromValue<void*>(editCustomAvs2YUVParams));
-       editCustomAvs2YUVParams->addAction(editorActionAvs2YUV);
-       connect(editorActionAvs2YUV, SIGNAL(triggered(bool)), this, SLOT(editorActionTriggered()));
+       ADD_CONTEXTMENU_ACTION(editCustomX264Params, QIcon(":/buttons/page_edit.png"), tr("Open the Text-Editor"), editorActionTriggered);
+       ADD_CONTEXTMENU_ACTION(editCustomAvs2YUVParams, QIcon(":/buttons/page_edit.png"), tr("Open the Text-Editor"), editorActionTriggered);
+       ADD_CONTEXTMENU_SEPARATOR(editCustomX264Params);
+       ADD_CONTEXTMENU_SEPARATOR(editCustomAvs2YUVParams);
+       ADD_CONTEXTMENU_ACTION(editCustomX264Params, QIcon(":/buttons/page_copy.png"), tr("Copy to Clipboard"), copyActionTriggered);
+       ADD_CONTEXTMENU_ACTION(editCustomAvs2YUVParams, QIcon(":/buttons/page_copy.png"), tr("Copy to Clipboard"), copyActionTriggered);
+       ADD_CONTEXTMENU_ACTION(editCustomX264Params, QIcon(":/buttons/page_paste.png"), tr("Paste from Clipboard"), pasteActionTriggered);
+       ADD_CONTEXTMENU_ACTION(editCustomAvs2YUVParams, QIcon(":/buttons/page_paste.png"), tr("Paste from Clipboard"), pasteActionTriggered);
 
        //Setup template selector
        loadTemplateList();
@@ -668,6 +684,28 @@ void AddJobDialog::editorActionTriggered(void)
        }
 }
 
+void AddJobDialog::copyActionTriggered(void)
+{
+       if(QAction *action = dynamic_cast<QAction*>(QObject::sender()))
+       {
+               QClipboard *clipboard = QApplication::clipboard();
+               QLineEdit *lineEdit = reinterpret_cast<QLineEdit*>(action->data().value<void*>());
+               QString text = lineEdit->hasSelectedText() ? lineEdit->selectedText() : lineEdit->text();
+               clipboard->setText(text);
+       }
+}
+
+void AddJobDialog::pasteActionTriggered(void)
+{
+       if(QAction *action = dynamic_cast<QAction*>(QObject::sender()))
+       {
+               QClipboard *clipboard = QApplication::clipboard();
+               QLineEdit *lineEdit = reinterpret_cast<QLineEdit*>(action->data().value<void*>());
+               QString text = clipboard->text();
+               if(!text.isEmpty()) lineEdit->setText(text);
+       }
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Public functions
 ///////////////////////////////////////////////////////////////////////////////
index fd43e37..1217a92 100644 (file)
@@ -68,6 +68,8 @@ private slots:
        void saveTemplateButtonClicked(void);
        void deleteTemplateButtonClicked(void);
        void editorActionTriggered(void);
+       void copyActionTriggered(void);
+       void pasteActionTriggered(void);
        
        virtual void accept(void);