diff --git a/IHM_Retouche_Photo/colorpickerwidget.cpp b/IHM_Retouche_Photo/colorpickerwidget.cpp index 3b533c8766716dbde6cc15a0060af3ade71d3357..b44c2e4bedaf69efbb9b22fc74ab59424b0fd9a9 100644 --- a/IHM_Retouche_Photo/colorpickerwidget.cpp +++ b/IHM_Retouche_Photo/colorpickerwidget.cpp @@ -5,7 +5,8 @@ #include <QListWidgetItem> #include <QVBoxLayout> #include <QPushButton> - +#include <QPushButton> +#include <QKeyEvent> ColorPickerWidget::ColorPickerWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index cf3ca072d5e1115fcf1a52999d30166b9e47549c..366a7161a5fb4ddcec956e0cfbdfe0c180048039 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -32,6 +32,11 @@ MainWindow::MainWindow(QWidget * parent) // Connect the button's clicked signal to the openColorPicker slot connect(ColorWindow, &QPushButton::clicked, this, &MainWindow::openColorPicker); + // Create an action for Ctrl+C + ctrlCAction = new QAction(this); + ctrlCAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C)); // Change the shortcut + connect(ctrlCAction, &QAction::triggered, this, &MainWindow::handleCtrlCKey); + addAction(ctrlCAction); this->_viewManager = new ui::ViewManager(this->_fileselectorManager, this->_imageTabs); @@ -53,7 +58,11 @@ void MainWindow::openColorPicker() colorPickerWidget.show(); } - +void MainWindow::handleCtrlCKey() +{ + // Trigger the ColorWindow button when Ctrl+C is pressed + openColorPicker(); +} MainWindow::~MainWindow() { delete this->_fileselectorManager; delete this->_viewManager; diff --git a/IHM_Retouche_Photo/mainwindow.h b/IHM_Retouche_Photo/mainwindow.h index 288273b0064f42cc88a59f94e3cdc15fa36c4919..5f37e63e01f7e447c0944cbedd6a202676986c95 100644 --- a/IHM_Retouche_Photo/mainwindow.h +++ b/IHM_Retouche_Photo/mainwindow.h @@ -11,6 +11,8 @@ #include "ui/view/viewmanager.h" #include <colorpickerwidget.h> +class QAction; + class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT private: @@ -28,8 +30,11 @@ class MainWindow : public QMainWindow, private Ui::MainWindow { virtual void dragEnterEvent(QDragEnterEvent *e); private slots: void openColorPicker(); // Slot to open the ColorPickerWidget + void handleCtrlCKey(); // New slot for Ctrl+C + private: ColorPickerWidget colorPickerWidget; // Declare ColorPickerWidget as a private member QPushButton *ColorWindow; // Assuming you have a QPushButton in your UI + QAction *ctrlCAction; // New QAction for Ctrl+C }; diff --git a/IHM_Retouche_Photo/mainwindow.ui b/IHM_Retouche_Photo/mainwindow.ui index f9eb51d64b13a37be1be3502f80141d80e574c8b..5fc5b187d2a53e00a35cf4896793076ce0b776d9 100644 --- a/IHM_Retouche_Photo/mainwindow.ui +++ b/IHM_Retouche_Photo/mainwindow.ui @@ -322,7 +322,7 @@ <item> <widget class="QPushButton" name="ColorWindow"> <property name="text"> - <string>Open Color Picker</string> + <string>Open Color Picker (Ctrl+Shift+C)</string> </property> </widget> </item> diff --git a/build-IHM_Retouche_Photo-Desktop_Qt_6_3_0_GCC_64bit-Debug/ui_mainwindow.h b/build-IHM_Retouche_Photo-Desktop_Qt_6_3_0_GCC_64bit-Debug/ui_mainwindow.h index 6cbfc249a8384ceb1695fe9ca73c0df92e3e3e02..5e402ea57951bab42e77615d067170df1a8a7351 100644 --- a/build-IHM_Retouche_Photo-Desktop_Qt_6_3_0_GCC_64bit-Debug/ui_mainwindow.h +++ b/build-IHM_Retouche_Photo-Desktop_Qt_6_3_0_GCC_64bit-Debug/ui_mainwindow.h @@ -695,7 +695,7 @@ public: #endif // QT_CONFIG(shortcut) _imageTabs->setTabText(_imageTabs->indexOf(_imageTabs_1), QCoreApplication::translate("MainWindow", "Blank", nullptr)); _imageTabs->setTabText(_imageTabs->indexOf(_imageTabs_2), QCoreApplication::translate("MainWindow", "Tab 2", nullptr)); - ColorWindow->setText(QCoreApplication::translate("MainWindow", "Open Color Picker", nullptr)); + ColorWindow->setText(QCoreApplication::translate("MainWindow", "Open Color Picker (Ctrl+Shift+C)", nullptr)); #if QT_CONFIG(tooltip) _toolbox->setToolTip(QString()); #endif // QT_CONFIG(tooltip)