- fix: when oj problem grabbed by competitive companion received,
the app is restored to normal state, no matter it's current state. - enhancement: input shortcut in the option dialog's general -> shortcut page by pressing keys.
This commit is contained in:
parent
f7a6db7005
commit
5e349ec21e
5
NEWS.md
5
NEWS.md
|
@ -1,3 +1,8 @@
|
||||||
|
Red Panda C++ Version 1.0.3
|
||||||
|
- fix: when oj problem grabbed by competitive companion received,
|
||||||
|
the app is restored to normal state, no matter it's current state.
|
||||||
|
- enhancement: input shortcut in the option dialog's general -> shortcut page by pressing keys.
|
||||||
|
|
||||||
Red Panda C++ Version 1.0.2
|
Red Panda C++ Version 1.0.2
|
||||||
- enhancement: press tab in column mode won't exit column mode
|
- enhancement: press tab in column mode won't exit column mode
|
||||||
- enhancement: refine behavior of undo input space char
|
- enhancement: refine behavior of undo input space char
|
||||||
|
|
|
@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty(APP_VERSION) {
|
isEmpty(APP_VERSION) {
|
||||||
APP_VERSION=1.0.2
|
APP_VERSION=1.0.3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ SOURCES += \
|
||||||
widgets/qpatchedcombobox.cpp \
|
widgets/qpatchedcombobox.cpp \
|
||||||
widgets/searchdialog.cpp \
|
widgets/searchdialog.cpp \
|
||||||
widgets/searchresultview.cpp \
|
widgets/searchresultview.cpp \
|
||||||
|
widgets/shortcutinputedit.cpp \
|
||||||
widgets/signalmessagedialog.cpp
|
widgets/signalmessagedialog.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
@ -326,6 +327,7 @@ HEADERS += \
|
||||||
widgets/qpatchedcombobox.h \
|
widgets/qpatchedcombobox.h \
|
||||||
widgets/searchdialog.h \
|
widgets/searchdialog.h \
|
||||||
widgets/searchresultview.h \
|
widgets/searchresultview.h \
|
||||||
|
widgets/shortcutinputedit.h \
|
||||||
widgets/signalmessagedialog.h
|
widgets/signalmessagedialog.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
|
|
@ -3309,6 +3309,7 @@ void MainWindow::onNewProblemConnection()
|
||||||
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(
|
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(
|
||||||
mOJProblemSetModel.count()-1
|
mOJProblemSetModel.count()-1
|
||||||
,0));
|
,0));
|
||||||
|
if (isMinimized())
|
||||||
showNormal();
|
showNormal();
|
||||||
raise(); // for mac OS?
|
raise(); // for mac OS?
|
||||||
activateWindow();
|
activateWindow();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "environmentshortcutwidget.h"
|
#include "environmentshortcutwidget.h"
|
||||||
#include "ui_environmentshortcutwidget.h"
|
#include "ui_environmentshortcutwidget.h"
|
||||||
#include "../mainwindow.h"
|
#include "../mainwindow.h"
|
||||||
|
#include "../widgets/shortcutinputedit.h"
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
EnvironmentShortcutWidget::EnvironmentShortcutWidget(const QString& name, const QString& group, QWidget *parent) :
|
EnvironmentShortcutWidget::EnvironmentShortcutWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||||
|
@ -24,9 +25,12 @@ EnvironmentShortcutWidget::EnvironmentShortcutWidget(const QString& name, const
|
||||||
ui(new Ui::EnvironmentShortcutWidget)
|
ui(new Ui::EnvironmentShortcutWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
mDelegate =new EnvironmentShortcutDelegate(this);
|
||||||
ui->tblShortcut->setModel(&mModel);
|
ui->tblShortcut->setModel(&mModel);
|
||||||
|
ui->tblShortcut->setItemDelegate(mDelegate);
|
||||||
connect(&mModel, &EnvironmentShortcutModel::shortcutChanged,
|
connect(&mModel, &EnvironmentShortcutModel::shortcutChanged,
|
||||||
this, &SettingsWidget::setSettingsChanged);
|
this, &SettingsWidget::setSettingsChanged);
|
||||||
|
mDelegate =new EnvironmentShortcutDelegate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentShortcutWidget::~EnvironmentShortcutWidget()
|
EnvironmentShortcutWidget::~EnvironmentShortcutWidget()
|
||||||
|
@ -92,7 +96,7 @@ QVariant EnvironmentShortcutModel::data(const QModelIndex &index, int role) cons
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
if (role==Qt::DisplayRole || role == Qt::EditRole) {
|
if (role==Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole) {
|
||||||
PEnvironmentShortcut item = mShortcuts[index.row()];
|
PEnvironmentShortcut item = mShortcuts[index.row()];
|
||||||
switch( index.column()) {
|
switch( index.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -173,3 +177,25 @@ void EnvironmentShortcutModel::loadShortCutsOfMenu(const QMenu *menu, QList<QAct
|
||||||
globalActions.removeAll(action);
|
globalActions.removeAll(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnvironmentShortcutDelegate::EnvironmentShortcutDelegate(
|
||||||
|
QObject *parent) : QStyledItemDelegate(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *EnvironmentShortcutDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isValid() && index.column()==1) {
|
||||||
|
ShortcutInputEdit *editor=new ShortcutInputEdit(dynamic_cast<QWidget*>(parent));
|
||||||
|
connect(editor,&ShortcutInputEdit::inputFinished,
|
||||||
|
this, &EnvironmentShortcutDelegate::onEditingFinished);
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
return QStyledItemDelegate::createEditor(parent,option,index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnvironmentShortcutDelegate::onEditingFinished(QWidget* editor)
|
||||||
|
{
|
||||||
|
emit commitData(editor);
|
||||||
|
emit closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define ENVIRONMENTSHORTCUTWIDGET_H
|
#define ENVIRONMENTSHORTCUTWIDGET_H
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "settingswidget.h"
|
#include "settingswidget.h"
|
||||||
#include "../shortcutmanager.h"
|
#include "../shortcutmanager.h"
|
||||||
|
@ -49,6 +50,18 @@ private:
|
||||||
void loadShortCutsOfMenu(const QMenu * menu, QList<QAction*>& globalActions);
|
void loadShortCutsOfMenu(const QMenu * menu, QList<QAction*>& globalActions);
|
||||||
private:
|
private:
|
||||||
QList<PEnvironmentShortcut> mShortcuts;
|
QList<PEnvironmentShortcut> mShortcuts;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class EnvironmentShortcutDelegate: public QStyledItemDelegate {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EnvironmentShortcutDelegate(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
protected slots:
|
||||||
|
void onEditingFinished(QWidget* editor);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EnvironmentShortcutWidget : public SettingsWidget
|
class EnvironmentShortcutWidget : public SettingsWidget
|
||||||
|
@ -68,6 +81,7 @@ protected:
|
||||||
void doSave() override;
|
void doSave() override;
|
||||||
private:
|
private:
|
||||||
EnvironmentShortcutModel mModel;
|
EnvironmentShortcutModel mModel;
|
||||||
|
EnvironmentShortcutDelegate* mDelegate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENVIRONMENTSHORTCUTWIDGET_H
|
#endif // ENVIRONMENTSHORTCUTWIDGET_H
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
|
<number>250</number>
|
||||||
|
</attribute>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include "shortcutinputedit.h"
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
ShortcutInputEdit::ShortcutInputEdit(QWidget* parent):QLineEdit(parent)
|
||||||
|
{
|
||||||
|
QList<QAction *> acts = actions();
|
||||||
|
foreach (const QAction* action, acts) {
|
||||||
|
qDebug()<<action->shortcut()[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutInputEdit::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key()==Qt::Key_Delete && event->modifiers()==Qt::NoModifier) {
|
||||||
|
setText("");
|
||||||
|
} else if (event->key()==Qt::Key_Backspace && event->modifiers()==Qt::NoModifier) {
|
||||||
|
setText("");
|
||||||
|
} else if (event->key()==Qt::Key_Control ||
|
||||||
|
event->key()==Qt::Key_Alt ||
|
||||||
|
event->key()==Qt::Key_Shift ||
|
||||||
|
event->key()==Qt::Key_Meta
|
||||||
|
) {
|
||||||
|
QKeySequence seq(event->modifiers());
|
||||||
|
setText("");
|
||||||
|
} else {
|
||||||
|
int key = event->key();
|
||||||
|
if (key==Qt::Key_Backtab)
|
||||||
|
key = Qt::Key_Tab;
|
||||||
|
QKeySequence seq(event->modifiers()|key);
|
||||||
|
setText(seq.toString());
|
||||||
|
if (key!=Qt::Key_Tab
|
||||||
|
&& key!=Qt::Key_Enter
|
||||||
|
&& key!=Qt::Key_Return)
|
||||||
|
emit inputFinished(this);
|
||||||
|
}
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShortcutInputEdit::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type()==QEvent::ShortcutOverride) {
|
||||||
|
keyPressEvent((QKeyEvent*)event);
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
} else if (event->type()==QEvent::KeyPress) {
|
||||||
|
keyPressEvent((QKeyEvent*)event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return QLineEdit::event(event);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef SHORTCUTINPUTEDIT_H
|
||||||
|
#define SHORTCUTINPUTEDIT_H
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class ShortcutInputEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ShortcutInputEdit(QWidget* parent);
|
||||||
|
signals:
|
||||||
|
void inputFinished(QWidget* editor);
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
|
// QObject interface
|
||||||
|
public:
|
||||||
|
bool event(QEvent *event) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SHORTCUTINPUTEDIT_H
|
|
@ -17,7 +17,7 @@ SUBDIRS += \
|
||||||
|
|
||||||
APP_NAME = RedPandaCPP
|
APP_NAME = RedPandaCPP
|
||||||
|
|
||||||
APP_VERSION = 1.0.2
|
APP_VERSION = 1.0.3
|
||||||
|
|
||||||
linux: {
|
linux: {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue