mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
-fixed RWindow
-MainWindow uses now RWindow for storing size and position -added stringlist header for GeneralDialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@688 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2f30ee6b1d
commit
483118daec
@ -102,7 +102,7 @@
|
||||
|
||||
/** Constructor */
|
||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||
: QMainWindow(parent, flags)
|
||||
: RWindow("MainWindow", parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -59,7 +59,7 @@ class SMPlayer;
|
||||
|
||||
class PeerStatus;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
class MainWindow : public RWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "rshare.h"
|
||||
#include "GeneralDialog.h"
|
||||
#include <util/stringutil.h>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
/** Constructor */
|
||||
@ -61,8 +62,6 @@ GeneralDialog::~GeneralDialog()
|
||||
bool
|
||||
GeneralDialog::save(QString &errmsg)
|
||||
{
|
||||
Q_UNUSED(errmsg);
|
||||
|
||||
_settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
|
||||
|
||||
_settings->setRunRetroshareOnBoot(
|
||||
@ -75,11 +74,9 @@ GeneralDialog::save(QString &errmsg)
|
||||
void
|
||||
GeneralDialog::load()
|
||||
{
|
||||
|
||||
ui.chkRunRetroshareAtSystemStartup->setChecked(
|
||||
_settings->runRetroshareOnBoot());
|
||||
|
||||
|
||||
ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#ifndef _GENERALDIALOG_H
|
||||
#define _GENERALDIALOG_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <QFileDialog>
|
||||
#include <QLineEdit>
|
||||
@ -54,7 +55,7 @@ private slots:
|
||||
|
||||
private:
|
||||
/** A RetroShare Settings object used for saving/loading settings */
|
||||
RshareSettings* _settings;
|
||||
RshareSettings *_settings;
|
||||
|
||||
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
#include <QPalette>
|
||||
#include <QShortcut>
|
||||
#include <QByteArray>
|
||||
#include <QKeySequence>
|
||||
#include <QDesktopWidget>
|
||||
#include <rshare.h>
|
||||
#include "rwindow.h"
|
||||
|
||||
|
||||
@ -36,8 +36,7 @@ RWindow::RWindow(QString name, QWidget *parent, Qt::WFlags flags)
|
||||
: QMainWindow(parent, flags)
|
||||
{
|
||||
_name = name;
|
||||
_settings = new RshareSettings();
|
||||
_previouslyShown = false;
|
||||
_settings = new RSettings(name);
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
@ -51,8 +50,7 @@ RWindow::~RWindow()
|
||||
void
|
||||
RWindow::setShortcut(QString shortcut, const char *slot)
|
||||
{
|
||||
QShortcut *s = new QShortcut(QKeySequence(shortcut), this, slot, 0);
|
||||
Q_UNUSED(s);
|
||||
rApp->createShortcut(QKeySequence(shortcut), this, this, slot);
|
||||
}
|
||||
|
||||
/** Saves the size and location of the window. */
|
||||
@ -73,7 +71,10 @@ RWindow::restoreWindowState()
|
||||
{
|
||||
#if QT_VERSION >= 0x040200
|
||||
QByteArray geometry = getSetting("Geometry", QByteArray()).toByteArray();
|
||||
restoreGeometry(geometry);
|
||||
if (geometry.isEmpty())
|
||||
adjustSize();
|
||||
else
|
||||
restoreGeometry(geometry);
|
||||
#else
|
||||
QRect screen = QDesktopWidget().availableGeometry();
|
||||
|
||||
@ -115,25 +116,14 @@ void
|
||||
RWindow::setVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
/* If this is the first time this window is shown, restore its window
|
||||
* position and size. */
|
||||
if (!_previouslyShown) {
|
||||
#if !defined (Q_WS_WIN)
|
||||
/* Use the standard palette on non-Windows, overriding whatever was
|
||||
* specified in the .ui file for this dialog. */
|
||||
setPalette(QPalette());
|
||||
#endif
|
||||
|
||||
restoreWindowState();
|
||||
_previouslyShown = true;
|
||||
}
|
||||
|
||||
/* Bring the window to the top, if it's already open. Otherwise, make the
|
||||
* window visible. */
|
||||
if (isVisible()) {
|
||||
activateWindow();
|
||||
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
||||
raise();
|
||||
} else {
|
||||
restoreWindowState();
|
||||
}
|
||||
} else {
|
||||
/* Save the last size and position of this window. */
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <QWidget>
|
||||
#include <QVariant>
|
||||
#include <QMainWindow>
|
||||
#include <gui/Preferences/rsharesettings.h>
|
||||
#include <gui/Preferences/rsettings.h>
|
||||
|
||||
|
||||
class RWindow : public QMainWindow
|
||||
@ -68,8 +68,7 @@ signals:
|
||||
|
||||
private:
|
||||
QString _name; /**< Name associated with this window. */
|
||||
RshareSettings* _settings; /**< Object used to store window properties */
|
||||
bool _previouslyShown; /**< True if show() has been called for this window. */
|
||||
RSettings* _settings; /**< Object used to store window properties */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QTextStream>
|
||||
#include <QShortcut>
|
||||
#include <QStyleFactory>
|
||||
#include <gui/common/vmessagebox.h>
|
||||
#include <gui/common/html.h>
|
||||
@ -413,4 +414,12 @@ Rshare::log(Log::LogLevel level, QString msg)
|
||||
return _log.log(level, msg);
|
||||
}
|
||||
|
||||
|
||||
/** Creates and binds a shortcut such that when <b>key</b> is pressed in
|
||||
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
||||
void
|
||||
Rshare::createShortcut(const QKeySequence &key, QWidget *sender,
|
||||
QWidget *receiver, const char *slot)
|
||||
{
|
||||
QShortcut *s = new QShortcut(key, sender);
|
||||
connect(s, SIGNAL(activated()), receiver, slot);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QApplication>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "util/log.h"
|
||||
#include "gui/Preferences/rsharesettings.h"
|
||||
@ -106,6 +107,11 @@ public:
|
||||
* running() will be emitted when the event loop has started. */
|
||||
static int run();
|
||||
|
||||
/** Creates and binds a shortcut such that when <b>key</b> is pressed in
|
||||
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
||||
static void createShortcut(const QKeySequence &key, QWidget *sender,
|
||||
QWidget *receiver, const char *slot);
|
||||
|
||||
signals:
|
||||
/** Emitted when the application is running and the main event loop has
|
||||
* started. */
|
||||
|
Loading…
Reference in New Issue
Block a user