mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Improved auto resizing of screen.
This commit is contained in:
parent
79221b2eda
commit
09781236eb
6 changed files with 76 additions and 17 deletions
|
@ -130,6 +130,23 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
int w,h;
|
||||
qreal scale;
|
||||
|
||||
|
||||
w=ui->EmuScreen->screen_width;
|
||||
h=ui->EmuScreen->screen_height+5;
|
||||
if(!h) h=80;
|
||||
if(!w) w=131;
|
||||
scale=((qreal)event->size().width())/w;
|
||||
if((int)scale<1) scale=1.0;
|
||||
if(event->size().height()*0.40<scale*h) scale=event->size().height()*0.40/h;
|
||||
ui->EmuScreen->setScale((int)scale);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_EmuScreen_destroyed()
|
||||
{
|
||||
|
@ -351,6 +368,8 @@ struct mousemap {
|
|||
{ Qt::Key_Control, 62 ,0.00862069,0.161638, 0.817505,0.886406 },
|
||||
{ Qt::Key_Home, 63 ,0.00862069,0.118534, 0.918063,0.979516 },
|
||||
|
||||
{ Qt::Key_F10, 64 ,0.872845,0.987069, 0.108007,0.163873 },
|
||||
|
||||
// ADD MORE KEYS HERE
|
||||
|
||||
{ 0,0 , 0.0,0.0,0.0,0.0 }
|
||||
|
@ -1119,10 +1138,16 @@ if(obj == ui->KeybImage)
|
|||
if( (relx>=ptr->left)&&(relx<=ptr->right)&&(rely>=ptr->top)&&(rely<=ptr->bot)) {
|
||||
// CLICKED INSIDE A KEY
|
||||
|
||||
if(ptr->keynum==64) {
|
||||
// PRESSED THE SIMULATED MAIN MENU KEY
|
||||
menuBar()->activateWindow();
|
||||
}
|
||||
else {
|
||||
//TODO: HIGHLIGHT IT FOR VISUAL EFFECT
|
||||
__pckeymatrix|=1ULL<<(ptr->keynum);
|
||||
__keyb_update();
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ protected:
|
|||
virtual void keyReleaseEvent(QKeyEvent *ev);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_EmuScreen_destroyed();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1076</width>
|
||||
<height>598</height>
|
||||
<width>546</width>
|
||||
<height>900</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
|
@ -26,25 +26,25 @@
|
|||
<property name="styleSheet">
|
||||
<string notr="true">background: black;</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item alignment="Qt::AlignTop">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QEmuScreen" name="EmuScreen">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>528</width>
|
||||
<height>364</height>
|
||||
<width>132</width>
|
||||
<height>91</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>528</width>
|
||||
<height>364</height>
|
||||
<width>1056</width>
|
||||
<height>728</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
|
@ -70,7 +70,7 @@
|
|||
<item>
|
||||
<widget class="QPushButton" name="KeybImage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -83,7 +83,7 @@
|
|||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>464</width>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -100,7 +100,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-image: url(:/bitmap/bitmap/keyboard.png) 0 0 0 0 repeat stretch;
|
||||
<string notr="true">border-image: url(:/bitmap/bitmap/keyboard.png) 0 0 0 0 stretch stretch;
|
||||
border-width: 0px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -118,8 +118,8 @@ border-width: 0px;</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1076</width>
|
||||
<height>19</height>
|
||||
<width>546</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -325,7 +325,7 @@ win32: LIBS += -lsetupapi
|
|||
|
||||
android: SOURCES += external/hidapi/libusb/hid.c
|
||||
android: INCLUDEPATH += external/libusb-1.0.22/libusb/
|
||||
android: LIBS += -L$$PWD/external/libusb-1.0.22/android/libs -lusb
|
||||
android: LIBS += -L$$PWD/external/libusb-1.0.22/android/libs/armeabi-v7a -lusb1.0
|
||||
|
||||
freebsd: SOURCES += external/hidapi/libusb/hid.c
|
||||
freebsd: LIBS += -lusb -lthr -liconv
|
||||
|
@ -343,4 +343,22 @@ contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
|
|||
$$PWD/external/libusb-1.0.22/android/libs/armeabi-v7a/libusb1.0.so
|
||||
}
|
||||
|
||||
DISTFILES += \
|
||||
android/AndroidManifest.xml \
|
||||
android/gradle/wrapper/gradle-wrapper.jar \
|
||||
android/gradlew \
|
||||
android/res/values/libs.xml \
|
||||
android/build.gradle \
|
||||
android/gradle/wrapper/gradle-wrapper.properties \
|
||||
android/gradlew.bat \
|
||||
android/AndroidManifest.xml \
|
||||
android/gradle/wrapper/gradle-wrapper.jar \
|
||||
android/gradlew \
|
||||
android/res/values/libs.xml \
|
||||
android/build.gradle \
|
||||
android/gradle/wrapper/gradle-wrapper.properties \
|
||||
android/gradlew.bat
|
||||
|
||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
||||
|
||||
|
||||
|
|
|
@ -119,8 +119,8 @@ QEmuScreen::QEmuScreen(QWidget *parent) :
|
|||
setScene(&scr);
|
||||
setSceneRect(0,-5,screen_width,screen_height+5);
|
||||
centerOn(qreal(screen_width)/2,qreal(screen_height)/2);
|
||||
scale(4.0,4.0);
|
||||
|
||||
m_scale=1.0;
|
||||
setScale(4.0);
|
||||
|
||||
|
||||
show();
|
||||
|
@ -140,6 +140,17 @@ void QEmuScreen::setWord(int offset,unsigned int color)
|
|||
}
|
||||
}
|
||||
|
||||
void QEmuScreen::setScale(qreal _scale)
|
||||
{
|
||||
scale(_scale/m_scale,_scale/m_scale);
|
||||
m_scale=_scale;
|
||||
|
||||
QSize s;
|
||||
s.setWidth(0);
|
||||
s.setHeight((screen_height+5)*m_scale);
|
||||
setMinimumSize(s);
|
||||
}
|
||||
|
||||
|
||||
void QEmuScreen::update()
|
||||
{
|
||||
|
@ -215,3 +226,4 @@ void QEmuScreen::update()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
// SIZE OF THE SCREEN TO EMULATE
|
||||
int screen_width;
|
||||
int screen_height;
|
||||
qreal m_scale;
|
||||
// MAIN COLORS, ALL GRAYS WILL BE INTERPOLATED
|
||||
QColor BkgndColor;
|
||||
QColor MainColor;
|
||||
|
@ -36,8 +37,10 @@ public:
|
|||
void setPixel(int offset,int color);
|
||||
void setWord(int offset,unsigned int color);
|
||||
void setMode(int _mode,unsigned int *_buffer);
|
||||
void setScale(qreal _scale);
|
||||
explicit QEmuScreen(QWidget *parent = 0);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in a new issue