Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

More compact see-through dialog Restore maximized main window after returning from fullscreen

justburner06cb3307aeff
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index 23a6059f7..11ff6c21b 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -1078,15 +1078,19 @@ void MainWindow::maximizePanel() {
}
void MainWindow::fullScreenWindow() {
- if (isFullScreen())
- showNormal();
- else {
+ if (isFullScreen()) {
+ if (m_wasMaximized)
+ showMaximized();
+ else
+ showNormal();
+ } else {
#if defined(_WIN32)
// http://doc.qt.io/qt-5/windows-issues.html#fullscreen-opengl-based-windows
this->winId();
QWindowsWindowFunctions::setHasBorderInFullScreen(this->windowHandle(),
true);
#endif
+ m_wasMaximized = isMaximized();
this->showFullScreen();
}
}
diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.h
index 50cf2a903..865d0c5dc 100644
--- a/toonz/sources/toonz/mainwindow.h
+++ b/toonz/sources/toonz/mainwindow.h
@@ -58,6 +58,7 @@ class MainWindow final : public QMainWindow {
bool m_saveSettingsOnQuit;
bool m_startupPopupShown = false;
+ bool m_wasMaximized = false;
int m_oldRoomIndex;
QString m_currentRoomsChoice;
UpdateChecker *m_updateChecker;
diff --git a/toonz/sources/toonz/seethroughwindowpopup.cpp b/toonz/sources/toonz/seethroughwindowpopup.cpp
index 8210eca14..14fd84b8a 100644
--- a/toonz/sources/toonz/seethroughwindowpopup.cpp
+++ b/toonz/sources/toonz/seethroughwindowpopup.cpp
@@ -9,7 +9,7 @@
#include <QApplication>
#include <QMainWindow>
-#include <QToolTip>
+#include <QDialog>
TEnv::IntVar SeeThroughWindowOpacity("SeeThroughWindowOpacity", 50);
@@ -17,16 +17,14 @@ TEnv::IntVar SeeThroughWindowOpacity("SeeThroughWindowOpacity", 50);
SeeThroughWindowPopup::SeeThroughWindowPopup()
: Dialog(TApp::instance()->getMainWindow(), true, false, "SeeThroughWindow") {
- setWindowTitle(tr("See Through Mode"));
+ setWindowTitle(tr("See Through Mode (Main Window)"));
setModal(false);
- m_bckValue = 50;
+ m_suffixTxtSlider = "% " + tr("Opacity");
- beginHLayout();
+ m_bckValue = 50;
- m_opacityLabel = new QLabel(tr("Opacity:"));
- m_opacityLabel->setMinimumHeight(25);
- addWidget(m_opacityLabel);
+ m_layout = new QBoxLayout(QBoxLayout::LeftToRight);
m_opacitySlider = new QSlider(Qt::Horizontal);
m_opacitySlider->setRange(1, 50);
@@ -34,13 +32,13 @@ SeeThroughWindowPopup::SeeThroughWindowPopup()
m_opacitySlider->setPageStep(5);
setOpacitySlider(SeeThroughWindowOpacity);
m_opacitySlider->setMinimumHeight(25);
- addWidget(m_opacitySlider);
+ m_layout->addWidget(m_opacitySlider);
m_seeThroughIcon_off = createQIcon("toggle_seethroughwin_off");
m_seeThroughIcon_on = createQIcon("toggle_seethroughwin_on");
QString tooltip =
- tr("Quickly toggle semi-transparent and full opaque.") + "\n" +
+ tr("Quickly toggle main window semi-transparency and full opacity.") + "\n" +
tr("Hold ALT while clicking to use full transparency instead.") + "\n" +
tr("When slider is at 100% it acts as ALT is held.");
@@ -48,17 +46,21 @@ SeeThroughWindowPopup::SeeThroughWindowPopup()
m_opacityBtn->setCheckable(true);
m_opacityBtn->setToolTip(tooltip);
m_opacityBtn->setFocusPolicy(Qt::NoFocus);
- m_opacityBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
- m_opacityBtn->setFixedWidth(25);
- m_opacityBtn->setMinimumHeight(25);
- addWidget(m_opacityBtn);
-
- endHLayout();
+ m_opacityBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_opacityBtn->setFixedSize(25, 25);
+ m_layout->addWidget(m_opacityBtn);
m_closeBtn = new QPushButton(tr("Disable See Through Mode"));
+ m_closeBtn->setToolTip(m_closeBtn->text());
m_closeBtn->setDefault(true);
m_closeBtn->setFocusPolicy(Qt::NoFocus);
+ beginVLayout();
+ addLayout(m_layout);
+ endVLayout();
+ addButtonBarWidget(m_closeBtn);
+ resizeEvent(nullptr); // set proper orientation
+
bool ret = true;
ret = ret && connect(m_opacitySlider, SIGNAL(valueChanged(int)), this,
@@ -67,8 +69,6 @@ SeeThroughWindowPopup::SeeThroughWindowPopup()
connect(m_opacityBtn, SIGNAL(clicked()), this, SLOT(opacityToggle()));
ret = ret && connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(accept()));
assert(ret);
-
- addButtonBarWidget(m_closeBtn);
}
//-----------------------------------------------------------------------------
@@ -90,6 +90,16 @@ void SeeThroughWindowPopup::hideEvent(QHideEvent *e) {
//-----------------------------------------------------------------------------
+void SeeThroughWindowPopup::resizeEvent(QResizeEvent *e) {
+ bool portrait = width() >= height();
+ m_layout->setDirection(portrait ? QBoxLayout::LeftToRight
+ : QBoxLayout::TopToBottom);
+ m_opacitySlider->setOrientation(portrait ? Qt::Orientation::Horizontal
+ : Qt::Orientation::Vertical);
+}
+
+//-----------------------------------------------------------------------------
+
int SeeThroughWindowPopup::getOpacitySlider() {
return m_opacitySlider->value() * 2;
}
@@ -107,7 +117,7 @@ int SeeThroughWindowPopup::setOpacitySlider(int opacity) {
void SeeThroughWindowPopup::sliderChanged(int value) {
int opacity = getOpacitySlider();
TApp::instance()->getMainWindow()->setWindowOpacity((double)opacity / 100);
- m_opacitySlider->setToolTip(QString::number(opacity) + "%");
+ m_opacitySlider->setToolTip(QString::number(opacity) + m_suffixTxtSlider);
if (m_opacityBtn->isChecked()) {
m_opacityBtn->setChecked(false);
m_opacityBtn->setIcon(m_seeThroughIcon_on);
diff --git a/toonz/sources/toonz/seethroughwindowpopup.h b/toonz/sources/toonz/seethroughwindowpopup.h
index eba26b6e1..82170d203 100644
--- a/toonz/sources/toonz/seethroughwindowpopup.h
+++ b/toonz/sources/toonz/seethroughwindowpopup.h
@@ -5,16 +5,18 @@
#include <QLabel>
#include <QSlider>
#include <QPushButton>
+#include <QBoxLayout>
class SeeThroughWindowPopup final : public DVGui::Dialog {
Q_OBJECT
int m_bckValue;
+ QBoxLayout *m_layout;
- QLabel *m_opacityLabel;
QSlider *m_opacitySlider;
QPushButton *m_opacityBtn;
QPushButton *m_closeBtn;
+ QString m_suffixTxtSlider;
QIcon m_seeThroughIcon_off;
QIcon m_seeThroughIcon_on;
@@ -27,6 +29,7 @@ public:
private:
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;
+ void resizeEvent(QResizeEvent *) override;
int getOpacitySlider();
int setOpacitySlider(int opacity);